// 函数节流
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);
},
网友评论