methods中
setTime() //设置定时器{ this.clearTimeSet=setInterval(() => { this.webSocketClientOnopen(); }, 1000);},clearTime() //清除定时器{ clearInterval(this.clearTimeSet);}
mounted 中
mounted : function () //页面加载完毕就开始加载定时器{ this.setTime();}beforeDestroy() { //页面关闭时清除定时器
clearInterval(this.clearTimeSet);},
转载于:https://www.cnblogs.com/benbenbai/p/10683495.html
转载请注明原文地址: https://win8.8miu.com/read-1496978.html