Is there any way to let directive listen to its component's event in vue 2.0?

51 views Asked by At
<template>
    <my-input v-my-directive="xxx"></my-input>
</template>

inside MyInput file:

<template>
    <div class="my-input" @someEvent="trigger">
        <input type="text"/>
    </div>
</template>
<script>
    export default {
         name: 'MyInput',
         methods: {
             trigger(){
                 this.$emit('someEvent')
             }
         }
    }
</script>

inside MyDirective file

export default Vue.directive('my-directive', {
     bind(el, binding, vnode) {
        // listen to someEvent here
     }
})

I want this v-my-directive listen my-input's event. But I can't find any way to achieve this.

0

There are 0 answers