💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] > [npm](https://www.npmjs.com/package/pinia-plugin-persist-uni) ## 概述 通过在你的 stroe 中配置 persist, 将会通过 uniAppStorage 来持久化存储你的数据. 安装 ``` npm i pinia-plugin-persist-uni ``` ## 示例 ### vue 3 vue ``` import { createApp } from 'vue' import { createPinia } from 'pinia' import piniaPersist from 'pinia-plugin-persist-uni' const pinia = createPinia() pinia.use(piniaPersist) createApp({}).use(pinia).mount('#app') ``` Typescript ``` // tsconfig.json { "compilerOptions": { "types": ["pinia-plugin-persist-uni"] } } ``` 基本用法 ``` // store/user.ts import { defineStore } from 'pinia' export const useUserStore = defineStore('storeUser', { state: () => { id: 'user', return { firstName: 'allen', lastName: 'ttk', accessToken: 'xxxxxxxxxxxxx', } }, actions: { setToken(value: string) { this.accessToken = value }, }, persist: { enabled: true, }, }) ```