element ui防止按钮连续点击
1.在main.js里添加/* 延迟按钮点击指令 */Vue.directive(‘dbClick’, {inserted(el, binding) {console.log(el)el.addEventListener(‘click’, e => {if (!el.disabled) {el.disabled = trueel.style.cursor = ‘not-allowed’set
·
1.在main.js里添加
/* 延迟按钮点击指令 */
Vue.directive(‘dbClick’, {
inserted(el, binding) {
console.log(el)
el.addEventListener(‘click’, e => {
if (!el.disabled) {
el.disabled = true
el.style.cursor = ‘not-allowed’
setTimeout(() => {
el.style.cursor = ‘pointer’
el.disabled = false
}, 3000)
}
})
}
})
2.在按钮上直接加上 v-dbClick <el-button size=“small” type=“primary” @click=“getList” v-dbClick>查询
更多推荐
已为社区贡献1条内容
所有评论(0)