在vue中使用setTimeout(function,delay) 和 setInterval(function,delay)
发表于:2023-01-12 15:54:21浏览:132次
注意事项:methods里面的方法必须放置方法里面,并且必须在外部定义this
//methods里面的方法必须放置方法里面,并且必须在外部定义this
let _this = this
_this.eventInterval = setInterval(function () {
_this.functionName()
},1000)
_this.eventTimeout = setTimeout(function () {
_this.functionName()
},1000)
//在离开页面的时候关闭
destroyed(){
let _this = this;
clearInterval(_this.eventInterval)
clearTimeout(_this.eventTimeout)
}
栏目分类全部>