vue:路由地址改变后销毁定时器

data () {
  return {
    timer: null   //定义
  }
},
beforeDestroy () {
  clearInterval(this.timer)
  console.log('组件销毁之前销毁定时器')
}

methods: {
	funName () {
		//设置定时器
		  this.timer = setInterval(() => {
		    ...
		  }, 1500)
	}
},

猜你喜欢

转载自blog.csdn.net/weixin_41143662/article/details/84302945