prevent:null,//防抖
canUse:true,//节流
userName:'前',
add:0
// 防抖
fangdou(){
if(this.prevent){
//清除痕迹
clearTimeout(this.prevent)
}
this.prevent = setTimeout(()=>{
this.prevent=null
//3秒后赋值
this.userName = '触发后'
},3000)
},
//节流
jieliu(){
if(this.canUse){
this.add++
//触发技能后,关闭开关
this.canUse = false
//在3秒后打开开关
setTimeout(()=>this.canUse = true, 3000)
}
}