Pinia 是 Vue 的官方状态管理库(Vuex 的继任者)— 一个用于存储需要在许多组件间共享的状态的集中式 store,拥有构建在 Composition API 之上的简洁、类型安全的 API。
定义一个 store
js
{ defineStore } ;
{ ref, computed } ;
useCounterStore = (, {
count = ();
double = ( count. * );
() { count.++; }
() { count. = api.(); }
{ count, double, increment, fetchInitial };
});
