utils.js

//防止多次重复点击  (函数节流) function throttle(fn, gapTime) {  if (gapTime == null || gapTime == undefined) {    gapTime = 1000  }  let _lastTime = null  // 返回新的函数  return function (e) {    console.log(this)    let _nowTime = + new Date()    if (_nowTime - _lastTime > gapTime || !_lastTime) {      // fn.apply(this, arguments)   //将this和参数传给原函数      fn(this,e)    //上方法不可行的解决办法 改变this和e      _lastTime = _nowTime    }  }}module.exports = {  throttle: throttle}

页面js

//mine.jsbindUpload: utils.throttle((that,e) => {       console.log(e)    //    事件源    console.log(that)  // this 指向  }, 1000)微信小程序

TAG标签: 微信小程序微信操作频繁

http://www.xiaochengxub.com/read-106614.html