window.addEventListener('beforeunload', this.deleteDocListener)
import { Prompt } from 'react-router-dom'
this.state:{
isPromt: true,
}
{nowSub ? null : (
<Prompt
message={(location)=>{
if (!isPromt) {
return true
}
const _this = this;
confirm({
title: '您还有尚未完成的编辑草稿,离开将不会保存,是否要离开?',
okText: '确定',
cancelText: '取消',
onOk () {
_this.feishuDocRef.deleteDocEvent()
console.log('OK');
_this.setState({
isPromt: false
},()=>{
_this.props.history.push(location.pathname)
})
},
onCancel() {
console.log('Cancel');
},
})
return false
}}
when={true} />