vue watch监听vuex中的数据变化

  watch: {
    "$store.state.isNewTitle": {
      //深度监听,可监听到对象、数组的变化
      handler(val,oldVal) {
          if(val){
              this.getMenuList();
          }
      },
      deep: true, //true 深度监听
    },
  },

val:更新后的值;

oldVal:更新前的旧值;

猜你喜欢

转载自blog.csdn.net/slow097/article/details/125478815