## main.js
//防止多次点击,重复提交
Vue.directive("preventReClick", {
inserted(el, binding) {
el.addEventListener("click", () => {
if (!el.disabled) {
el.disabled = true
console.log(binding.value)
setTimeout(() => {
el.disabled = false
}, binding.value || 150000)
}
})
}
})
## 使用
<a-button
key="submit"
type="primary"
@click="submit()"
v-preventReClick>
提交
</a-button>
vue 防止多次点击重复提交v-preventReClick
最新推荐文章于 2024-07-30 10:56:44 发布