Open yhf2000 opened 1 year ago
componentWillMount () { // 拦截判断是否离开当前页面 window.addEventListener('beforeunload', this.beforeunload); } componentWillUnmount () { // 销毁拦截判断是否离开当前页面 window.removeEventListener('beforeunload', this.beforeunload); } beforeunload (e) { let confirmationMessage = '你确定离开此页面吗?'; (e || window.event).returnValue = confirmationMessage; return confirmationMessage; }