throttle(fn, gapTime) {
if (gapTime == null || gapTime == undefined) {
gapTime = 1000
}
let _lastTime = null
return function (e) {
let _nowTime = +new Date()
if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments)
_lastTime = _nowTime
}
}
},
使用方法:
丢app.js里然后全局引用app
myFunction: app.globalData.throttle(function () {
})