You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
431 B
18 lines
431 B
3 years ago
|
/**
|
||
|
* @description 节流指令
|
||
|
* 限制连续快速点击按钮
|
||
|
* 用例:<Tag v-throttle>text</Tag>
|
||
|
* */
|
||
|
|
||
|
export default {
|
||
|
inserted(el, binding, vnode) {
|
||
|
el.addEventListener("click", () => {
|
||
|
if (!el.disabled) {
|
||
|
el.disabled = true;
|
||
|
setTimeout(() => {
|
||
|
el.disabled = false;
|
||
|
}, binding.value || 1000);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
};
|