1

I have a parent component which has child A and child B, child B has Child C inside it.

So I need to trigger an event from child A to Child C, what is the best way to to this?

Or maybe is there a way to watch for a change in the store.state?

CommonSenseCode
  • 23,522
  • 33
  • 131
  • 186
  • 2
    Possible duplicate of [Communication between sibling components in VueJs 2.0](https://stackoverflow.com/questions/38616167/communication-between-sibling-components-in-vuejs-2-0) – thanksd May 22 '17 at 15:20

1 Answers1

2

Since you're using a store, I assume Vuex, just watch the store state change. To do that, you need to bring that piece of the store into your component with a computed property. Then watch the computed property.

{
    computed:{
        myProp(){
            return this.$store.state.myProp
        }
    },
    watch:{
        myProp(){
            //myProp changed
        }
    }
}
Eric Guan
  • 15,474
  • 8
  • 50
  • 61