上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 59 下一页
摘要: 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 左扬 阅读(67) 评论(0) 推荐(0)
摘要: Vuex 4.x https://vuex.vuejs.org/zh/ 一、Vue是什么? Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式+库。它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化。 1.1、什么是 "状态管理模式"? 状态管理模 阅读全文
posted @ 2023-11-13 15:50 左扬 阅读(110) 评论(0) 推荐(0)
摘要: provide、inject、mixins、extends 一、provide 用于提供可以被后代组件注入的值。 interface ComponentOptions { provide?: object | ((this: ComponentPublicInstance) => object) } 阅读全文
posted @ 2023-11-13 11:03 左扬 阅读(453) 评论(0) 推荐(0)
摘要: 异步组件 一、基本用法 在大型项目中,我们可能需要拆分应用为更小的块,并仅在需要时再从服务器加载相关组件。Vue 提供了defineAsyncComponent方法来实现此功能: import { defineAsyncComponent } from 'vue' const AsyncComp = 阅读全文
posted @ 2023-11-10 11:17 左扬 阅读(116) 评论(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 左扬 阅读(970) 评论(0) 推荐(0)
摘要: Teleport <Teleport>是一个内置组件,它可以将一个组件内部的一部分模板“传送”到该组件的 DOM 结构外层的位置去。 一、基本用法 https://cn.vuejs.org/guide/built-ins/teleport.html#basic-usage 有时我们可能会遇到这样的场 阅读全文
posted @ 2023-11-09 16:19 左扬 阅读(146) 评论(0) 推荐(0)
摘要: Element Plus 组件库 一、Element Plus 基于 Vue 3,面向设计师和开发者的组件库。 二、完整导入 https://element-plus.org/zh-CN/guide/quickstart.html#完整引入 如果你对打包后的文件大小不是很在乎,那么使用完整导入会更方 阅读全文
posted @ 2023-11-08 16:18 左扬 阅读(625) 评论(0) 推荐(0)
摘要: 插槽 一、匿名插槽 App.vue: <script setup> import A from './FancyButton.vue' </script> <template> <A> 这是 XXXX 数据 </A> </template> FancyButton.vue: <template> < 阅读全文
posted @ 2023-11-08 15:16 左扬 阅读(192) 评论(0) 推荐(0)
摘要: 兄弟组件之间的传值 一、第一种方案 A组件-->父组件-->B组件 1.1、A组件 <template> <div> <h1>A组件</h1> <button @click="changeA">按钮</button> </div> </template> <script setup lang='ts 阅读全文
posted @ 2023-11-06 16:13 左扬 阅读(439) 评论(0) 推荐(0)
摘要: 组件传值方式1 —— props / $emit(父子传值 ) 一、父传子 1.1、父组件通过 props 传递数据 在父组件中,创建了一个名为List的子组件实例,并通过:msg="msg"语法将父组件的msg数据传递给子组件。这里的msg是一个响应式引用(使用ref创建),初始值为'这是父传过去 阅读全文
posted @ 2023-11-02 17:21 左扬 阅读(752) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 59 下一页