From e04f249245b06f517d9a467d8fb8fa1c6f7bc8ba Mon Sep 17 00:00:00 2001 From: zhangsir Date: Tue, 7 May 2024 08:48:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=E6=8F=90=E4=BA=A4=E6=94=B9?= =?UTF-8?q?=E4=B8=BA5=E7=A7=92=E5=86=85=E5=8F=AA=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Course/exam.vue | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/Course/exam.vue b/src/components/Course/exam.vue index d4b4d7b7..1e4c26d5 100644 --- a/src/components/Course/exam.vue +++ b/src/components/Course/exam.vue @@ -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); }, }