嗨,我想知道如何在浏览器选项卡关闭时提示消息.
handleWindowClose(){
alert("Alerted Browser Close");
},
componentDidMount: function() {
window.addEventListener('onbeforeunload', this.handleWindowClose);
},
componentWillUnmount: function() {
window.removeEventListener('onbeforeunload', this.handleWindowClose);
}
这就是我try 添加到react组件中的内容.请指导我如何进一步进行.