VUE中使用lodash的debounce和throttle方法

说明:

debounce和throttle在脚手架的使用,此处以防抖函数debounce为例避免按钮被重复点击

引入:

import lodash from 'lodash'

使用:

直接使用debounce方法

//  审核
      audit: lodash.debounce(function() {
          this.$refs['model'].saveTotalResult(1).then(() => {
            const reportId = this.activeReport.id;
            report.audit(reportId).then(res => {
                 successMsg(res.msg)
            })
          })
        }, 300),

 

posted @ 2021-02-05 18:01  vickylinj  阅读(1933)  评论(0编辑  收藏  举报