vue 自定义指令防抖

directives: {
    throttle: {
      bind: (el, value) => {
        var falg = null
        el.addEventListener('click', function (event) {
          if (falg) {
            event.stopImmediatePropagation()
          } else {
            falg = setTimeout(() => {
              falg = null
            }, 10000)
          }
        }, true)
      }
    }
  },
<el-button type="primary"
                   icon="el-icon-check"
                   @click="submitForm"
                   v-throttle>确 定</el-button>

猜你喜欢

转载自blog.csdn.net/qq_27449993/article/details/122964816