you can access other component data and methods from another component

Solved this with Vuex:

store.js


    import Vue from 'vue';
    import Vuex from 'vuex';
    
    Vue.use(Vuex);
    
    const store = new Vuex.Store({
      state: {
        profile_page: 'profile',
      },
      mutations: {
        changePage(state, page) {
          state.profile_page = page;
        }
      },
    });
    
    export default store

And then commit the state on both parent and child component, i made a method with the commit statement inside the method:

    changePage(page) {
       this.$store.commit('changePage', page);
    },

and add a click event afterwards inside the html tag like this:


    @click="changePage("page_name")"

Problem solved.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top