store页面index.js

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
  topath:''
  },
  mutations: {
   
   
    "TO_PTATH" : function (state,pth) {
      state.topath = pth;

    }
  },
  getters: {
   
  },
  actions: {
  }
});
export default store

监听页面:

  computed: {
      listenshowpage1() {
        return this.$store.state.topath;
      }
    },
    watch:{
      listenshowpage1:function(old,newd){
        console.log(old)
          this.temp = old;
         }
    }

值改变页面:

  addTask(){
          this.$store.commit("TO_PTATH",'/taskHeadAdd');
        
        },

 

Logo

前往低代码交流专区

更多推荐