页面刷新时是否调用了 Vue 的“销毁”方法?

244*_*boy 4 javascript vue.js

我想知道刷新运行 Vue 应用程序的页面是否会触发 Vue 的.destroyed回调。

从我在包含这些简单生命周期回调的 Vue 应用程序中观察到的:

created() {
  console.log(' created');
},
destroyed() {
  console.log('destroyed')?
}
Run Code Online (Sandbox Code Playgroud)

'created'记录(不记录'destroyed')。如何检查.destroyed回调是否已执行?

onu*_*tan 7

我在stackoverflow上找到了类似的问题和答案

在重新加载或关闭 vue.js 之前做一些事情

他/她基本上解释说页面重新加载时没有任何东西被破坏,您需要定义

window.onbeforeunload = function(){
  return "Are you sure you want to close the window?";
}
Run Code Online (Sandbox Code Playgroud)

如果你想在页面刷新之前做一些事情