/**
 * @Author: zhangtq 2452618307@qq.com
 * @Date: 2025-01-17 13:36:43
 * @LastEditors: zhangtq 2452618307@qq.com
 * @LastEditTime: 2025-01-17 13:37:14
 * @FilePath: src/utils/preventReClick.js
 * @Description: vue 提交表单重复点击，重复提交防抖问题
 */

export default {
  install (Vue) {
    // 防止按钮重复点击
    Vue.directive('preventReClick', {
      inserted (el, binding) {
        // console.log("binding-7", binding)
        el.addEventListener('click', () => {
          if (!el.disabled) {
            el.disabled = true
            setTimeout(() => {
              el.disabled = false
            }, binding.value || 2000)
          }
        })
      }
    })
  }
}
