Vue中监听store中state的数据的方法


computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper;
    },
    LifeVal() {
      return this.$store.state.LifeVal;
    },
    danceVal(){
      return this.$store.state.danceVal;
    }
  },
 
  watch: {
   
    danceVal: function() {
        LifeVal = this.$store.state.LifeVal = this.$store.state.danceVal
/* vuex : changeDanceVal是store中mutations 里的方法
  // 修改state的唯一方法,只允许同步函数
   mutations: {
     // 第一个参state值,第二个接收触发方法时传来的值
     changeDanceVal(state,num) {
      state.LifeVal = num;
     }
   },
*/
        this.$store.commit("changeDanceVal"LifeVal);
      
    }
  },


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM