const throttle = function(func, duration) { let start = 0 return function() { let that = this let now = Date.now(); if (now - start > duration) { func.apply(that, arguments); start = now } else { wx.showToast({ title: `您的操作太频繁啦,请在${Math.ceil(duration/1000)}秒后再试哦~`, icon: 'none' }) } } } module.exports = { throttle }