上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 53 下一页
摘要: 定义Store Store 是用defineStore()定义的,它的第一个参数要求是一个独一无二的名字: import { defineStore } from 'pinia' // 你可以对 `defineStore()` 的返回值进行任意命名,但最好使用 store 的名字,同时以 `use` 阅读全文
posted @ 2023-11-14 14:56 左扬 阅读(1143) 评论(0) 推荐(0) 编辑
摘要: Pinia —— Store 是什么? https://pinia.vuejs.org/zh/getting-started.html#what-is-a-store 一、Store 是什么? Store (如 Pinia) 是一个保存状态和业务逻辑的实体,它并不与你的组件树绑定。换句话说,它承载着 阅读全文
posted @ 2023-11-14 10:20 左扬 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 安装 Pinia 用你喜欢的包管理器安装 pinia: yarn add pinia # 或者使用 npm npm install pinia 安装结束。 阅读全文
posted @ 2023-11-14 10:13 左扬 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 介绍 Pinia https://pinia.vuejs.org/zh/introduction.html 一、简介 https://pinia.vuejs.org/zh/introduction.html#introduction Pinia 起始于 2019 年 11 月左右的一次实验,其目的是 阅读全文
posted @ 2023-11-14 09:52 左扬 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Vuex 4.x —— Getter https://vuex.vuejs.org/zh/guide/getters.html 有时候我们需要从store中的state中派生出一些状态,例如对列表进行过滤并计数: computed: { doneTodosCount () { return this 阅读全文
posted @ 2023-11-13 17:35 左扬 阅读(27) 评论(0) 推荐(0) 编辑
摘要: Vuex 4.x —— state https://vuex.vuejs.org/zh/guide/state.html 一、单一状态树 https://vuex.vuejs.org/zh/guide/state.html#单一状态树 Vuex 使用单一状态树——是的,用一个对象就包含了全部的应用层 阅读全文
posted @ 2023-11-13 16:34 左扬 阅读(26) 评论(0) 推荐(0) 编辑
摘要: Vuex 4.x https://vuex.vuejs.org/zh/ 一、Vue是什么? Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式+库。它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化。 1.1、什么是 "状态管理模式"? 状态管理模 阅读全文
posted @ 2023-11-13 15:50 左扬 阅读(45) 评论(0) 推荐(0) 编辑
摘要: provide、inject、mixins、extends 一、provide 用于提供可以被后代组件注入的值。 interface ComponentOptions { provide?: object | ((this: ComponentPublicInstance) => object) } 阅读全文
posted @ 2023-11-13 11:03 左扬 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 异步组件 一、基本用法 在大型项目中,我们可能需要拆分应用为更小的块,并仅在需要时再从服务器加载相关组件。Vue 提供了defineAsyncComponent方法来实现此功能: import { defineAsyncComponent } from 'vue' const AsyncComp = 阅读全文
posted @ 2023-11-10 11:17 左扬 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 动态组件 一、App.vue <template> <ul> <!-- 使用ul标签替代了错误的url标签,用于展示列表 --> <li v-for='(item, index) in tabList' :key='index' @click="() => { currentComponent.co 阅读全文
posted @ 2023-11-10 10:43 左扬 阅读(780) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 53 下一页
levels of contents