Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


VueJS Trigger another component function

01 Sep 2020 » frontend

https://www.reddit.com/r/vuejs/comments/bavfig/trigger_function_from_another_component/

Vue.prototype.bus = new Vue()

this.bus.$emit('your-call', argument)
this.bus.$on('your-call', () => {
    
})
mounted(){
    this.bus.$on('your-call', () => {
        
    })
},
beforeDestroy(){
    this.bus.$off('your-call', () => {
        
    })
}

Related Posts