vuex常见用法

/**
 * vuex for VisPanel
 */
import Vue from 'vue'
import Vuex from 'vuex'
import * as types from './type'
import store from '@/store'

Vue.use(Vuex);

const state = {
  listLenght: '111'
}

const mutations = {
  [types.SETLISTLENGHT](state, args) {
    state.listLenght = args;
  }
}
const getters = {
  getlistLenght: state => {
      console.log(state)
    return state.listLenght;
  }
}

const actions = {
  setListLenght: ({commit}, args) => {
    commit(types.SETLISTLENGHT, args)
  }
}

store.registerModule('portal2', {
  state,
  mutations,
  getters,
  actions,
  strict: process.env.NODE_ENV !== 'production'
})

猜你喜欢

转载自blog.csdn.net/qq_37339364/article/details/84137286