// 函数节流const createClosure = function (callback) { var timer; return function (params) { if (timer) { return;
};
callback(params);
timer = setTimeout(() => {
clearTimeout(timer);
timer = null;
}, 1000);
}
}; onLoad: function (options) { // 闭包防止多次点击
this.doNext = createClosure(this.nextQuestion);
}, /**
* 点击【√】
*/answerCorrect: function () { this.doNext(true);
},/**
* 点击【X】
*/answerError: function () { this.doNext(false);
},
作者:谭瞎
链接:https://www.jianshu.com/p/c2947a3a99ad