摘要: `pinia-plugin-persistedstate` 丰富的功能可以使 Pinia Store 的持久化更易配置: - 与 [`vuex-persistedstate`](https://github.com/robinvdvleuten/vuex-persistedstate) 相似的 AP 阅读全文
posted @ 2023-08-13 14:27 蕝戀 阅读(1865) 评论(0) 推荐(0) 编辑
摘要: `store` 是一个用 `reactive` 包装的对象,这意味着不需要在 getters 后面写 `.value`,就像 `setup` 中的 `props` 一样,**如果你写了,我们也不能解构它**: ```Vue ``` 为了从 store 中提取属性时保持其响应性,你需要使用 `stor 阅读全文
posted @ 2023-08-13 14:26 蕝戀 阅读(2938) 评论(0) 推荐(1) 编辑
摘要: 使用pinia的action异步获取频道分类列表数据并渲染到页面中。 接口: GET请求,[http://geek.itheima.net/v1_0/channels](http://geek.itheima.net/v1_0/channels) store/channel.js ```Vue im 阅读全文
posted @ 2023-08-13 14:26 蕝戀 阅读(118) 评论(0) 推荐(0) 编辑
摘要: - 在项目根目录创建store文件夹(此步骤和vuex相同) - 在步骤一的store文件夹下根据不同的用途场景创建单独的store文件(等同于vuex中分模块)、 ![](https://secure2.wostatic.cn/static/7tsMdHuR2i5hy79jHGjHZC/image 阅读全文
posted @ 2023-08-13 14:25 蕝戀 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 用你喜欢的js包管理器安装pinia: ```Bash yarn add pinia # 或者使用 npm npm install pinia ``` 创建一个 pinia 实例 (根 store) 并将其传递给应用: 编辑main.js: ```Vue import { createApp } f 阅读全文
posted @ 2023-08-13 14:25 蕝戀 阅读(39) 评论(0) 推荐(0) 编辑
摘要: 一款官方推荐的,代替vuex的,新的状态管理工具。 官方网: [https://pinia.vuejs.org/zh/introduction.html](https://pinia.vuejs.org/zh/introduction.html) **主要区别:** - 去除了modules的概念, 阅读全文
posted @ 2023-08-13 14:24 蕝戀 阅读(8) 评论(0) 推荐(0) 编辑