dishait / pinia-plugin-unistorage

uniapp 下 pinia 的本地数据缓存插件
MIT License
17 stars 2 forks source link

不支持ts 写法 #12

Open xuxichen opened 4 days ago

xuxichen commented 4 days ago

我的pinia 版本是"pinia": "2.0.33","pinia-plugin-unistorage": "^0.0.19", 在ts 项目中 piniaError

xuxichen commented 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, // 是否持久化