mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 09:56:45 +08:00
5秒内点击只生效一次
This commit is contained in:
@@ -92,8 +92,8 @@
|
||||
if(this.examId){
|
||||
this.loadExamInfo();
|
||||
}
|
||||
this.debouncedPresent = this.debounce(this.present, 500);
|
||||
this.confirmStop = this.debounce(this.submitTest,500)
|
||||
this.debouncedPresent = this.throttle(this.present, 5000);
|
||||
this.confirmStop = this.throttle(this.submitTest,5000)
|
||||
},
|
||||
methods: {
|
||||
changeTimer(){
|
||||
@@ -352,14 +352,14 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
debounce(func, delay) {
|
||||
let timerId;
|
||||
throttle(func, delay) {
|
||||
let lastExecTime = 0;
|
||||
return function (...args) {
|
||||
if (timerId) clearTimeout(timerId);
|
||||
timerId = setTimeout(() => {
|
||||
const now = Date.now();
|
||||
if (now - lastExecTime >= delay) {
|
||||
func.apply(this, args);
|
||||
timerId = null;
|
||||
}, delay);
|
||||
lastExecTime = now;
|
||||
}
|
||||
};
|
||||
},
|
||||
present(){
|
||||
|
||||
Reference in New Issue
Block a user