1 回答
TA贡献1828条经验 获得超3个赞
我试了一下,切换路由的时候能触发执行beforeDestroy方法,示例如下。
const Home = {
template: `
<div>
<div class="section">Some section foo</div>
<div class="section">Some section foo</div>
<div class="section">Some section foo</div>
<div class="section">Some section foo</div>
</div>
`,
mounted() {
console.log("Home mounted");
},
beforeDestroy() {
console.log("Home destroy");
}
};
const Test = {
template: `
<div>
<div class="section">Some section test</div>
<div class="section">Some section test</div>
<div class="section">Some section test</div>
<div class="section">Some section test</div>
</div>
`,
mounted() {
console.log("Test mounted");
},
beforeDestroy() {
console.log("Test destroy");
}
};
添加回答
举报