个人学习笔记
computed:{
goGrdoupRecor(){
var _this = this
if(this.show.allposShow===true){
setTimeout(function(){
_this.visible = false
},3000)
}else{
_this.visible = true
}
}
}
setTimeout 里的this 指向window
或
computed:{
goGrdoupRecor(){
if(this.show.allposShow===true){
setTimeout(()=>{
this.visible = false
},3000)
}else{
_this.visible = true
}
}
}
使用箭头函数 函数体内的this对象,就是定义时所在的对象,而不是使用时所在的对象。
最开始是显示3s后提示框消失,后来我想添加点击事件,点击时提示框显示,过三秒后消失,这时就需要清除定时器。




参考:https://blog.csdn.net/qq_21132509/article/details/83504522
网友评论