Open xuxichen opened 4 days ago
在types 文件夹下创建一个pinia.d.ts 文件 ` import 'pinia';
declare module 'pinia' {
export interface DefineStoreOptionsBase<S, Store> {
unistorage?: boolean | {
serializer?: {
serialize: (value: any) => string;
deserialize: (value: string) => any;
};
} | {
beforeRestore?: (ctx: any) => void;
afterRestore?: (ctx: any) => void;
} | {
key?: string;
paths?: string[];
};
}
}
填入如上代码可以支持在
defineStore('useStore',{
unistorage: true, // 是否持久化
}
`
中使用这个unistorage: true, // 是否持久化
我的pinia 版本是"pinia": "2.0.33","pinia-plugin-unistorage": "^0.0.19", 在ts 项目中![piniaError](https://github.com/dishait/pinia-plugin-unistorage/assets/18108140/cd699604-cd46-41f6-be6b-b044015ed383)