vue中使用lodash的throttle不生效解决方案

 问题:

     如下使用不会执行代码,打印节流

methods: {
    throttleHandler(){
_.throttle(function () {
      console.log('节流');
      this.submit()
    }, buttonThrottle)
},

 解决:

      需要改下如下写法

methods: {
    throttleHandler: _.throttle(function () {
      console.log('截流');
      this.submit()
    }, buttonThrottle),

 如果觉得对你有帮助,欢迎打赏  

热爱前端技术
原文地址:https://www.cnblogs.com/lcosima/p/14566334.html