我想知道刷新运行 Vue 应用程序的页面是否会触发 Vue 的.destroyed回调。
从我在包含这些简单生命周期回调的 Vue 应用程序中观察到的:
created() {
console.log(' created');
},
destroyed() {
console.log('destroyed')?
}
Run Code Online (Sandbox Code Playgroud)
仅'created'记录(不记录'destroyed')。如何检查.destroyed回调是否已执行?
我在stackoverflow上找到了类似的问题和答案
他/她基本上解释说页面重新加载时没有任何东西被破坏,您需要定义
window.onbeforeunload = function(){
return "Are you sure you want to close the window?";
}
Run Code Online (Sandbox Code Playgroud)
如果你想在页面刷新之前做一些事情
| 归档时间: |
|
| 查看次数: |
11167 次 |
| 最近记录: |