摘要:
使用state和mapState,轻松实现多组件间数据共享 阅读全文
posted @ 2025-01-07 22:19
市丸银
阅读(11)
评论(0)
推荐(0)
摘要:
1、安装 npm i nanoid 2、引入 import {nanoid} from 'nanoid' 3、使用 nanoid() 阅读全文
posted @ 2025-01-07 22:07
市丸银
阅读(40)
评论(0)
推荐(0)
摘要:
一、mapMutations 1、作用:帮助我们生成与mutations对话的方法,即包含 $store.commit() 2、步骤 a、引入 import {mapActions, mapMutations} from 'vuex' b、语法 methods:{ // mapMutations生成 阅读全文
posted @ 2025-01-07 21:40
市丸银
阅读(212)
评论(0)
推荐(0)
摘要:
一、作用 生成计算属性,简化模版{{xx}}xx的写法,原因xx在vuex中写法麻烦$store.state.x或$store.getters.x 二、步骤 1、引入 import {mapState, mapGetters} from 'vuex' 2、语法 computed:{ // 借助 ma 阅读全文
posted @ 2025-01-07 21:02
市丸银
阅读(31)
评论(0)
推荐(0)
摘要:
1、当state中的数据需要加工使用时,可以使用getters加工 2、在sindex.js中追加getters配置,注意别忘记创建和暴露 //准备state对象--保存具体数据 const state = { sum:0 } // 对state中的数据进行加工处理 const getters = 阅读全文
posted @ 2025-01-07 19:36
市丸银
阅读(59)
评论(0)
推荐(0)
摘要:
1、index.js import Vue from "vue"; import Vuex from "vuex" // 使用Vuex Vue.use(Vuex) // 准备actions对象--响应组件中的动作 const actions = { addOdd(context, value){ i 阅读全文
posted @ 2025-01-07 18:51
市丸银
阅读(5)
评论(0)
推荐(0)
摘要:
一、下载vuex 注意版本 vue2对应 npm i vuex@3 vue3对应 npm i vuex@4 二、创建文件 src/store/index.html import Vue from "vue"; import Vuex from "vuex" // 使用Vuex Vue.use(Vue 阅读全文
posted @ 2025-01-07 18:05
市丸银
阅读(9)
评论(0)
推荐(0)

浙公网安备 33010602011771号