@vue定时器和关闭定时器
vue定时器和关闭定时器
mounted() {//页面加载完成后执行方法(启动定时器)clearInterval(this.timer)this.setTimer()},//distroyed: function () {//页面关闭后关闭定时器(并没用)// console.log('distroyed')//clearInterval(this.timer)//},beforeDestroy() {//页面关闭前关闭定时器 (这个才有用)clearInterval(this.timer)},methods: {setTimer: function () {this.timer = setInterval( () => {console.log("定时执行方法");}, 3000);},}
vue生命周期 学习
/a/1190000008010666