index.js 395 B

1234567891011121314151617181920212223
  1. import Vue from 'vue'
  2. import Vuex from "vuex"
  3. Vue.use(Vuex)
  4. export default new Vuex.Store({
  5. // 全局属性变量
  6. state: { // state的作用是定义属性变量。定义一个参数
  7. theme: 'red_theme'
  8. },
  9. // 全局同步方法,在methods{this.$store.commit("changeTheme")}
  10. mutations: {
  11. changeTheme(state, value) {
  12. state.theme = value;
  13. }
  14. },
  15. getters: {
  16. },
  17. actions: {
  18. }
  19. })