Vue.js - Emit event from directive

后端 未结 7 460
北海茫月
北海茫月 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 13:34

    @euvl's solution is fine, but i think it's easier and cleaner to just pass a function as an argument to your directive. Seems to simplify the interface to your directive as well.

    
    
    
    
    
    

提交回复
热议问题