- 定义一个变量flag
- 编写一个方法(getcards_500)用来控制需要调用的(getcards),设定一定时间(这里是500毫秒)内不在触发getcards方法,用于防止多次触发
getcards_500(){
let that=this;
var timer;
if (that.flag) {
that.getcards(that.start)//调用需要触发的函数
}
that.flag = false;
clearTimeout(timer);
timer = setTimeout(()=>{that.flag = true}, 500);
},