react離開(kāi)頁(yè)面時(shí)清除當(dāng)前頁(yè)面的數(shù)據(jù)相關(guān)代碼routerWillLeave() {this.setState({ myData: [],
codeFile: [],
})}window.onbeforeunload = function (e) { e = e || window.event;
if (e) {
e.returnValue = '關(guān)閉提示'; this.setState({
myData: []
})
codeFileInfo = {}
}
return '關(guān)閉提示';
};這兩種方法都不行,請(qǐng)問(wèn)應(yīng)該怎么解決
react離開(kāi)頁(yè)面清除數(shù)據(jù)
躍然一笑
2018-12-17 09:55:01
