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