iview Button按钮 全局click事件vue拦截 节流 - 防抖 Throttle debounce
这里是按钮的节流,就没用防抖
const setVueClickGlobalThrottle = Vue => {
// 节流
const on = Vue.prototype.$on
Vue.prototype.$on = function (event, func) {
console.info('全局拦截 click $on事件 event', event)
let previous = 0
let newFunc = func
if (event === 'click') {
console.info('全局拦截 click 事件 setVueClickGlobalThrottle')
newFunc = function () {
const now = new Date().getTime()
if (previous + 1000 <= now) {
func.apply(this, arguments)
previous = now
}
}
}
on.call(this, event, newFunc)
}
}
export default setVueClickGlobalThrottle
main.js 里面加载
import setVueClickGlobalThrottle from '@/libs/common/setVueClickGlobalThrottle.js'
setVueClickGlobalThrottle(Vue) // 将所有click 进行节流处理
---------------------------------------------
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
https://pengchenggang.gitee.io/navigator/
SMART原则:
目标必须是具体的(Specific)
目标必须是可以衡量的(Measurable)
目标必须是可以达到的(Attainable)
目标必须和其他目标具有相关性(Relevant)
目标必须具有明确的截止期限(Time-based)
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
https://pengchenggang.gitee.io/navigator/
SMART原则:
目标必须是具体的(Specific)
目标必须是可以衡量的(Measurable)
目标必须是可以达到的(Attainable)
目标必须和其他目标具有相关性(Relevant)
目标必须具有明确的截止期限(Time-based)