Vue.js - Emit event from directive

后端 未结 7 468
北海茫月
北海茫月 2021-02-02 12:37

Is it possible to emit a custom event from the directive in the component to which this directive is attached.

I was expecting it to work as described

7条回答
  •  逝去的感伤
    2021-02-02 13:26

    Your solution was not working for me. Indeed vnode.data.on was always undefined

    What worked to trigger an event was

     vnode.child.$emit('myevent');
    

    Hope this helps.

提交回复
热议问题