mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 03:16:42 +08:00
考试提交改为5秒内只执行一次
This commit is contained in:
@@ -408,17 +408,18 @@ export default {
|
||||
this.curIndex++;
|
||||
this.curItem=this.paper.items[this.curIndex];
|
||||
},
|
||||
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(){ //提交前处理
|
||||
console.log('ssss')
|
||||
let $this=this;
|
||||
let score=this.countTest();
|
||||
console.log('score='+score);
|
||||
@@ -600,7 +601,7 @@ export default {
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.debouncedPresent = this.debounce(this.present, 500);
|
||||
this.debouncedPresent = this.throttle(this.present, 5000);
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user