首先下载Vuex
为了页面太多不好维护,在src中新建一个store文件夹,根目录当中创建一个index.js和modules文件夹,

index.js当中引入Vue和Vuex Vue.use(Vuex)全局引用组件

modules文件夹当中放每个模板对应的状态和方法
例如:

在main.js中引入使用

模板当中使用:

计算:

状态的使用 {{状态}},完美。
Amzing!!!
首先下载Vuex
为了页面太多不好维护,在src中新建一个store文件夹,根目录当中创建一个index.js和modules文件夹,
index.js当中引入Vue和Vuex Vue.use(Vuex)全局引用组件
modules文件夹当中放每个模板对应的状态和方法
例如:
在main.js中引入使用
模板当中使用:
计算:
状态的使用 {{状态}},完美。
Amzing!!!
本文标题:Vuex在Vue-cli当中的使用
本文链接:https://www.haomeiwen.com/subject/oznglftx.html
网友评论