摘要: 第一步:在store/index.js中 import Vue from 'vue' import Vuex from 'vuex' import cart from './modules/cart'; //在store的文件夹下新建一个modules/cart.js模块 Vue.use(Vuex) 阅读全文
posted @ 2021-06-10 19:17 是娜娜呀~ 阅读(354) 评论(0) 推荐(0)
摘要: 方法一: 在组件内部事件触发时,通过dispatch传参 methods:{ handleAddCount(){ //第一种 //在组件内部提交数据,以载荷的形式分发 this.$store.dispatch('increment',{ amount:10, }) //increment 是stor 阅读全文
posted @ 2021-06-10 19:16 是娜娜呀~ 阅读(303) 评论(0) 推荐(0)
摘要: 安装: npm install vuex --save vue add vuex 使用: 在store/index.js中 import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const store = new Vuex.Store 阅读全文
posted @ 2021-06-10 19:13 是娜娜呀~ 阅读(43) 评论(0) 推荐(0)
摘要: //在需要获取的页面引入 import {mapState,mapGetters,mapMutations,mapActions} from "vuex"; mapState的使用方法: export default { computed:{ //第一种写法 count(){ return this 阅读全文
posted @ 2021-06-10 19:09 是娜娜呀~ 阅读(150) 评论(0) 推荐(0)