this.$root.$emit not working in Vue

后端 未结 2 1499
粉色の甜心
粉色の甜心 2021-01-07 23:23

I want to emit an event on the root component, and listen to in in the root component. In a child of child component I do this:

this.$root.$emit(\'access-tok         


        
2条回答
  •  滥情空心
    2021-01-07 23:49

    You are not using the $root for the event $on

    Change this:

    this.$on('access-token', this.setAccessToken); 
    

    for this:

    this.$root.$on('access-token', this.setAccessToken);
    

提交回复
热议问题