diff --git a/src/url.ts b/src/url.ts new file mode 100644 index 00000000..03ed96bb --- /dev/null +++ b/src/url.ts @@ -0,0 +1 @@ +export const reqUrl = ' https://www.hndyjqrh.cn' \ No newline at end of file diff --git a/src/utils/throttle.ts b/src/utils/throttle.ts new file mode 100644 index 00000000..07b8d039 --- /dev/null +++ b/src/utils/throttle.ts @@ -0,0 +1,19 @@ +export const throttle = (func: (...args: any[]) => void, limit: number) => { + let lastFunc: ReturnType; + let lastRan: number | undefined; + + return function (this: any, ...args: any[]) { // 为 this 添加类型注解 + if (!lastRan) { + func.apply(this, args); + lastRan = Date.now(); + } else { + clearTimeout(lastFunc); + lastFunc = setTimeout(() => { + if (Date.now() - (lastRan as number) >= limit) { + func.apply(this, args); + lastRan = Date.now(); + } + }, limit - (Date.now() - (lastRan as number))); + } + }; +}; \ No newline at end of file diff --git a/src/views/index.vue b/src/views/index.vue index 80c9956b..3419d989 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -11,7 +11,8 @@
  • - 安保力量 + + 安保力量
  • @@ -58,12 +59,12 @@ diff --git a/src/views/page/indexMim.vue b/src/views/page/indexMim.vue index 84d27c90..9b538002 100644 --- a/src/views/page/indexMim.vue +++ b/src/views/page/indexMim.vue @@ -177,6 +177,7 @@