1.安装
npm i lodash
2.main.js全局引用
import _ from ‘lodash’
Vue.prototype._ = _
3.使用示例
在需要防抖的方法修改为
fun: _.debounce(function (e) {…},100}
注意:不可使用箭头函数代替,如 fun: _.debounce( (e)=> {…},100},箭头函数会导致里面的this指向undefined
<div @DOMMouseScroll="handleMouseWheel" ></div>
// methods中添加鼠标滚动事件
handleMouseWheel: _.debounce(function (e) {
this.ZoomSvg(-e.detail)
},30),