組件A:this.$store.commt('change')組件B:methods:{ methodA(){ ... }},computed:{ eventChange(){ return this.$store.state.eventChange }},watch:{ eventChange(val){ this.methodA() }}store:state:{ eventChange:false},mutations:{ change(state){ state.eventChange = !state.eventChange }}感覺繞了十萬八千里,有沒有什么簡單的辦法在組件A中直接觸發B組件中的事件,不考慮eventBus
vuex怎樣簡化跨組件觸發事件
拉莫斯之舞
2019-02-15 19:15:37