vue自定义指令

directives: {
    debounce: {
      inserted: (el, binding) => {
        let timer = null;
        el.addEventListener('click', () => {
          console.log(binding);
          if (!timer) {
            el.disabled = true;
            timer = setTimeout(() => {
              clearTimeout(timer);
              timer = null;
              el.removeAttribute('disabled');
            }, binding.value || 1000);
          }
        });
      },
    },
  },
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
上次更新: 4/10/2022, 10:26:50 AM