Communication between different components of vue

You can use the state in the store to communicate

Omit other codes in the store

B component related operations change the value in the store, A component listens for operations

B component:
 methods: {    change(idx){      other operations     . . .       ctx.$store.commit("SET_SIDE_MENU", sideMenu);     }}





A component:
 computed: {     getSideMenu() {       return this.$store.getters.sideMenu; //Monitor the data of the store that needs to be changed     }   },   watch: {     getSideMenu(newVal, oldVal) {   }






Guess you like

Origin blog.csdn.net/CarryBest/article/details/88975253