0๐
โ
you need to remove the event when you remove the component:
<script>
export default {
methods: {
go: function () {
console.log('event received')
}
},
created: function (){
this.$parent.$on('go', this.go);
},
beforeDestroy: function (){
this.$parent.$off('go',this.go);
}
}
<script>
0๐
You have click
method in created lifecycle hook, so it will get called whenever the children
component will be rendered.
Source:stackexchange.com