在自定义指令中,怎么覆盖添加在组件上的事件监听方法? #8145
Answered
by
chenxch
blinkJun
asked this question in
Help/Questions
-
比如 <button v-auth="'no'" @click="jump" ></button> // auth.js
app.directive('auth', function (el: HTMLElement, binding: any, vnode: VNode) {
const type = binding.arg
const value = binding.value
vnode.props = {
...vnode.props,
onClick:noAuthMessage
}
}) 我这样写是没有用的 |
Beta Was this translation helpful? Give feedback.
Answered by
chenxch
Apr 24, 2023
Replies: 1 comment 5 replies
-
先通过 el.removeEventListener('click', vnode.el._vei.onClick); 移除原有的点击事件,之后再添加新的click监听 |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
blinkJun
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
demo
先通过
移除原有的点击事件,之后再添加新的click监听