gpt4 book ai didi

javascript - Vue 的 'destroyed' 方法是否在页面刷新时调用?

转载 作者:搜寻专家 更新时间:2023-10-30 22:49:44 25 4
gpt4 key购买 nike

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

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

created() {
console.log(' created');
},
destroyed() {
console.log('destroyed');
}

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

最佳答案

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

Do something before reload or close in vue.js

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

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

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

关于javascript - Vue 的 'destroyed' 方法是否在页面刷新时调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56076087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com