上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 98 下一页
摘要: 1、actions addPersonApi(context){ axios.get('https://random-data-api.com/api/name/random_name').then( response=>{ context.commit('ADD_PERSON', {id:nano 阅读全文
posted @ 2025-01-08 10:15 市丸银 阅读(33) 评论(0) 推荐(0)
摘要: 一、模块化 1、几个组件定义几个对象 文件 src/store/index.js // 与count组件相关的optinos const countOptions = { actions:{}, mutations:{}, state:{}, getters:{} } // 与person组件 相关 阅读全文
posted @ 2025-01-08 08:41 市丸银 阅读(77) 评论(0) 推荐(0)
摘要: 使用state和mapState,轻松实现多组件间数据共享 阅读全文
posted @ 2025-01-07 22:19 市丸银 阅读(30) 评论(0) 推荐(0)
摘要: 1、安装 npm i nanoid 2、引入 import {nanoid} from 'nanoid' 3、使用 nanoid() 阅读全文
posted @ 2025-01-07 22:07 市丸银 阅读(74) 评论(0) 推荐(0)
摘要: 一、mapMutations 1、作用:帮助我们生成与mutations对话的方法,即包含 $store.commit() 2、步骤 a、引入 import {mapActions, mapMutations} from 'vuex' b、语法 methods:{ // mapMutations生成 阅读全文
posted @ 2025-01-07 21:40 市丸银 阅读(273) 评论(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 市丸银 阅读(52) 评论(0) 推荐(0)
摘要: 1、当state中的数据需要加工使用时,可以使用getters加工 2、在sindex.js中追加getters配置,注意别忘记创建和暴露 //准备state对象--保存具体数据 const state = { sum:0 } // 对state中的数据进行加工处理 const getters = 阅读全文
posted @ 2025-01-07 19:36 市丸银 阅读(81) 评论(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 市丸银 阅读(35) 评论(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 市丸银 阅读(26) 评论(0) 推荐(0)
摘要: 一、作用 父组件可以向子组件指定位置插入html结构,也是一种通信方式,适用于 父组件=>子组件 二、分类 默认插槽、具名插槽(有具体名字的插槽)、作用域插槽 三、使用方式 1、默认插槽 父组件 <Category title="美食" > <ul> <li v-for="data,index in 阅读全文
posted @ 2025-01-06 22:31 市丸银 阅读(89) 评论(0) 推荐(0)
上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 98 下一页