我在自定义指令中需要拦截传入的事件
export default {
name: 'disabled',
method: {
inserted(el, binding, vnode) {
let disabled = false
console.log(el.addEventListener) //能输出
el.addEventListener('click', async () => { //绑定的时候就报错
if (!disabled) {
disabled = true
const rs = await binding.value()
if (rs.disabled === false || rs === false)
disabled = false
}
})
}
}
}