I need trigger a function from one component to another. I don't know it's necessary or not . But whatever here is the solution for you -
Suppose two component. One of them we can called A component and another can be called as B component- So I will trigger A component function from B component.
In component A-
created() {
this.$root.$refs.A = this;
},
// and here is the method which I called from `B` component
methods:{
print(){
// your others function logic
console.log('A component function called')
},
And Now I called this print function from B component via a function.
In component B -
methods:{
printFromA(){
this.$root.$refs.A.print();
}
}
voila!!! check your console 😇
Thank You.
Top comments (0)