zoukankan      html  css  js  c++  java
  • 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);
          
        }
      },
  • 相关阅读:
    2-Rsync备份-全网备份
    1-Rsync备份-备份概述
    复杂声明学习总结
    EasyExcel的用法
    listvue
    解决Error: Cannot find module 'node-sass'问题
    Webpack
    babel的使用
    nodejs的使用
    vue入门
  • 原文地址:https://www.cnblogs.com/2Octobering/p/13153564.html
Copyright © 2011-2022 走看看