Vue Pinia Best Practices

作者 vuejs-aic9d355ff23f6MIT收錄於 2026年10月8日更新於 2026年10月8日

Pinia stores, state management patterns, store setup, and reactivity with stores.

AI 產生的概覽

關於 Vue Pinia 儲存設定、響應式陷阱與狀態管理模式的參考指南。

功能
此技能是純說明性參考,彙整常見的 Pinia 問題與最佳實務,並針對每個主題指向個別的參考文件。內容涵蓋儲存設定錯誤、解構與方法綁定等響應式問題,以及以 URL 為基礎的臨時篩選狀態和大型應用慣例等狀態模式。它產出的是指引與索引,而非程式碼或檔案。
適用情境
適用於使用 Pinia 的 Vue 應用,遇到儲存設定錯誤、響應式失效,或需要狀態管理慣例時。也適合在決定臨時篩選狀態應放在何處,或如何為較大型應用組織儲存時使用。
執行需求
無需指令碼或工具,僅為說明與參考文件。代理需要能夠存取隨附的參考檔案。

Pinia best practices, common gotchas, and state management patterns.

Store Setup

  • Getting "getActivePinia was called" error at startup → See pinia-no-active-pinia-error [blocked]
  • Setup stores missing state in DevTools or SSR → See pinia-setup-store-return-all-state [blocked]

Reactivity

  • Store destructuring stops updating UI reactively → See pinia-store-destructuring-breaks-reactivity [blocked]
  • Store methods lose context in template calls → See store-method-binding-parentheses [blocked]

State Patterns

  • Filters reset on refresh or can't be shared → See state-url-for-ephemeral-filters [blocked]
  • Building production app without DevTools or conventions → See state-use-pinia-for-large-apps [blocked]

來源與署名

來源:vuejs-ai/skills位於skills/vue-pinia-best-practices提交c9d355f

授權條款: MIT

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架