惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

程沛权 - 养了三只猫

适用于 Oxlint 与 Oxfmt 的 Oxc 优先工作流 Vue Picture Cropper 发布 1.x 版本 讲一讲背后的设计理念 年终总结:2025 年的一些回顾和 2026 年的一些小规划 Obsidian x 飞牛 NAS:打造免费的跨平台笔记同步与备份方案 适用于 ESLint V9 的现代化扁平化配置 解决 better-sqlite3 连接 SQLite 时报错 Could not locate the bindings file 本色十年 记录一次 ERR_INCOMPLETE_CHUNKED_ENCODING 的问题排查 使用 remark-directive 为 Unifiedjs 提供 Markdown 视频语法的解析 干净的 TypeScript 项目在编译时报错 Cannot find module 'undici-types' 的原因和解决 macOS 基于 Android Studio 修改模拟器 Hosts 给猫儿子的新年礼物 它很喜欢! 年终总结:2023 年的一些回顾和 2024 年的一些小规划 千元预算组装入门 NAS 设备 分享 NAS 的硬件基础知识 我写了一本书《前端工程化:基于 Vue.js 3.0 的设计与实践》 想分享一下它背后的故事 Git的选择性合并操作笔记:合并某个版本或某个提交 年终总结:2022 年的一些回顾和 2023 年的一些小规划 知乎收藏夹助手:自动化将专栏的文章添加到收藏夹 用Vite更简单的解决Vue3项目的预渲染问题 每天吃什么?上班带什么饭?程序员教你做菜啦!
Pinia怎么用?Vue3全局状态的管理工具Pinia教程
chengpeiquan@chengpeiquan.com (程沛权) · 2022-04-04 · via 程沛权 - 养了三只猫

本文最后更新于 4 年前,部分内容可能不适合当前所有情况,仅供参考。

Vue 官方推出的全局状态管理工具目前有 Vuex 和 Pinia ,两者的作用和用法都比较相似,但 Pinia 的设计更贴近 Vue 3 组合式 API 的用法。

教程地址

点击访问:全局状态的管理 查看完整内容。

为什么写这篇内容

截止至 2022 年 4 月, Pinia 还没有被广泛的默认集成在各种脚手架里,官网也只有英文版,整理了教程便于提前学习。

由于 Vuex 4.x 版本只是个过渡版,Vuex 4 对 TypeScript 和 Composition API 都不是很友好,虽然官方团队在 GitHub 已有讨论 Vuex 5 的开发提案,但从 2022-02-07 在 Vue 3 被设置为默认版本开始, Pinia 已正式被官方推荐作为全局状态管理的工具。

Pinia Logo
Pinia Logo

Pinia 支持 Vue 3 和 Vue 2 ,对 TypeScript 也有很完好的支持,延续了 Vue3 入门指南与实战案例 的宗旨,在这里只介绍基于 Vue 3 和 TypeScript 的用法。

欢迎 Star

教程属于 Vue3 入门指南与实战案例 的一部分,如果觉得对你有帮助,欢迎到仓库给个 Star 鼓励