@@ -108,6 +108,20 @@ router.beforeEach(async (to, from, next) => {
}
})
+
+//节流
+function throttle() {
+ let prev = 0
+ Vue.prototype.$throttle = function (func, wait) {
+ let now = Date.now()
+ if (now - prev > wait) {
+ func.apply(this)
+ prev = now
+ }
+}
+throttle()
/* eslint-disable no-new */
new Vue({
el: '#app',