报名工具小程序初始代码
This commit is contained in:
25
util/util.js
Normal file
25
util/util.js
Normal file
@@ -0,0 +1,25 @@
|
||||
function throttle(fn, gapTime) {
|
||||
if (gapTime == null || gapTime == undefined) {
|
||||
gapTime = 1500
|
||||
}
|
||||
|
||||
let _lastTime = null
|
||||
|
||||
// 返回新的函数
|
||||
return function() {
|
||||
let _nowTime = +new Date()
|
||||
if (_nowTime - _lastTime > gapTime || !_lastTime) {
|
||||
fn.apply(this, arguments) //将this和参数传给原函数
|
||||
_lastTime = _nowTime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
throttle: throttle,
|
||||
vuemixin: {
|
||||
created: function() {
|
||||
console.log(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user