diff --git "a/\351\273\204\345\244\251\344\274\237/20240513-paina.md" "b/\351\273\204\345\244\251\344\274\237/20240513-paina.md" new file mode 100644 index 0000000000000000000000000000000000000000..e02f353e7ee75e85df198c20406cf77c81bd4853 --- /dev/null +++ "b/\351\273\204\345\244\251\344\274\237/20240513-paina.md" @@ -0,0 +1,67 @@ +**Pinia 是一个基于 Vue 3 的状态管理库,它提供了类似 Vuex 的状态管理功能,但使用了更现代化的 API 和更好的 TypeScript 支持。** + +#### 安装 Pinia +```bash +npm install pinia +``` + +#### 创建 Pinia Store + +```vue + +``` + +#### 在组件中使用 Pinia Store +```vue + + + +``` + +在这个示例中,定义了一个名为 `useCounterStore` 的 Pinia Store,并在组件中使用 `useCounterStore` 来获取该 Store 的实例,然后通过 `store` 对象访问状态、操作和 getters。 + +#### 使用插件 + +```javascript +import { createApp } from 'vue'; +import { createPinia } from 'pinia'; +import App from './App.vue'; + +const app = createApp(App); +app.use(createPinia()); +app.mount('#app'); +``` \ No newline at end of file