4 changed files with 6 additions and 72 deletions
-
37vue/gold-system/src/util/index.js
-
1vue/gold-system/src/views/consume/addConsume.vue
-
39vue/gold-system/src/views/recharge/addRecharge.vue
-
1vue/gold-system/src/views/refund/addRefund.vue
@ -1,37 +0,0 @@ |
|||
// 防抖
|
|||
function _debounce(fn, delay = 500) { |
|||
var timer = null; |
|||
return function () { |
|||
var _this = this; |
|||
var args = arguments; |
|||
if (timer) clearTimeout(timer); |
|||
timer = setTimeout(function () { |
|||
fn.apply(_this, args); |
|||
}, delay); |
|||
}; |
|||
} |
|||
|
|||
// 节流
|
|||
function _throttle(fn, delay = 1000) { |
|||
var lastTime, timer, delay; |
|||
return function () { |
|||
var _this = this; |
|||
var args = arguments; |
|||
var nowTime = Date.now(); |
|||
if (lastTime && nowTime - lastTime < delay) { |
|||
if (timer) clearTimeout(timer); |
|||
timer = setTimeout(function () { |
|||
lastTime = nowTime; |
|||
fn.apply(_this, args); |
|||
}, delay) |
|||
} else { |
|||
lastTime = nowTime; |
|||
fn.apply(_this, args); |
|||
} |
|||
} |
|||
} |
|||
|
|||
export { |
|||
_debounce, |
|||
_throttle, |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue