lodash防抖

import _ from "lodash";
const infoBoxDebounce = _.debounce(fc => fc(), 500, { leading: true });

//方法
clickMethod(){
  infoBoxDebounce(()=>{
  
    //代码块
 
 })
}

<script>
import _ from 'lodash'
export default {
  methods: {
    //方法
    clickMethod:_.debounce(function(){

    //代码块

    },1000)
  }
}
</script>

<script>
import _ from 'lodash'
export default {
  methods: {
    //方法
    clickMethod:_.debounce(() => {

        //代码块

    },1000)
  }
}
</script>

lodash防抖

上一篇:函数防抖


下一篇:函数防抖与函数节流