[Vuejs]-Vue.js : How can I do native events handling of child component from parent component

0👍

You used the .stop event modifier (calls event.stopImmediatePropagation()), but the behavior you’re seeking is accomplished with .prevent (calls event.preventDefault()):

<wrapper-link @click.prevent="onClickEvent" />
Vue.component('wrapper-link', {
  template: `
    <div>
      <a href="http://google.com"
         target="_blank"
         v-on="$listeners">Google</a>
    </div>
  `
});

new Vue({
  el: '#app',
  methods: {
    onClick(e) {
      console.log('click');
    }
  }
})
<script src="https://unpkg.com/vue@2.5.17"></script>

<div id="app">
  <wrapper-link @click.prevent="onClick" />
</div>
👤tony19

Leave a comment