服务器之家:专注于服务器技术及软件下载分享
分类导航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服务器之家 - 编程语言 - JavaScript - vue离开当前页面触发的函数代码

vue离开当前页面触发的函数代码

2021-09-07 16:33姚辉乾 JavaScript

这篇文章主要介绍了vue离开当前页面触发的函数代码,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

我就废话不多说了,大家还是直接看代码吧~

?
1
2
3
destroyed(){
 console.log('销毁')
}

补充知识:vue中进入路由页面和离开路由页面后执行函数

进入路由页面

?
1
2
3
4
5
mounted(){
   this.$nextTick(()=>{
    show();
  })
}

离开路由页面后执行函数

?
1
2
3
4
destroyed: function () {
      console.log("我已经离开了!");
  this.stopTimer();
 },

说明:destroyed是与methods、mounted同层级的

?
1
2
3
4
5
6
7
mounted(){
  this.startTimer();
},
//离开当前页面后执行
destroyed: function () {
  this.stopTimer();
},

以上这篇vue离开当前页面触发的函数代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/qq_33026699/article/details/80745966

延伸 · 阅读

精彩推荐