摘要: 创建module store.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const state = { count: 1 } const mutations={ add(state,n){ state.count+= 阅读全文
posted @ 2020-04-19 17:17 程序员徐小白 阅读(135) 评论(0) 推荐(0)
摘要: 先创建actions和方法 store.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const state = { count: 1 } const mutations={ add(state,n){ state.co 阅读全文
posted @ 2020-04-19 17:01 程序员徐小白 阅读(387) 评论(0) 推荐(0)
摘要: 通过this.$store.getters来使用 store.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const state = { count: 1 } const getters={ count(state){ 阅读全文
posted @ 2020-04-19 16:35 程序员徐小白 阅读(1010) 评论(0) 推荐(0)
摘要: 直接通过$store.commit调用 <button @click="$store.commit('mutations中的方法名','可带参数')">调用</button> 不需要再进行其他配置 通过在methods中注册方法调用 //先引入mapMutations import {mapMuta 阅读全文
posted @ 2020-04-19 15:47 程序员徐小白 阅读(4776) 评论(0) 推荐(0)
摘要: store.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const state = { count: 1 } export default new Vuex.Store({ state,mutations }) 直接通 阅读全文
posted @ 2020-04-19 15:04 程序员徐小白 阅读(2005) 评论(1) 推荐(0)
摘要: 首先先创建一个store.js 安装vue,vuex什么的就不说了 这是一个仓库 import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) //装载数据的一个仓库 const state = { count: 1 } //修改仓库的方法 阅读全文
posted @ 2020-04-19 00:31 程序员徐小白 阅读(66) 评论(0) 推荐(0)