前言我找了很多,就是这个.$once支持Vue2,试了下报错,发现Vue3被去掉了,伤心,记录下解决方法。1.在data中声明data(){return{timer:null,}}2.在mountedhook中定义scheme和处理函数mounted(){this.timer=setInterval(()=>{//处理部分},3000)},3.在beforeUnmount或者unmounted的hook中销毁beforeUnmount(){clearInterval(this.timer)this.timer=null;},亲测,好用~以上参考链接官方文档链接
