vuex状态管理详细使用方法

1安装:
vue ui
或cnpm install vuex


2/使用
import vuex from 'vuex'

vue.use(vuex)

var store = new Vuex.store({

})


var app = new Vue({
 store:store
})

3/安装vue插件,vue.js devtools,插件github地址:https://github.com/vuejs/vue-devtools
进入网上谷歌应用店
搜索vue
安装
重启浏览器


4使用

1、初始化state
2、设置更改state方法,将方法放进mutation里
3、触发state更改的方法,store.commit这个方法去触发mutation里的方法

原文地址:https://www.cnblogs.com/wwthuanyu/p/9999466.html