pinia数据持久化,定义persist时,报红线,打包也报错?
pinia代码部分
家人们,有没有知道该怎么处理的啊,我试着把这段函数注释了,就能打包了,但是就是报错显示,
下面是报错的提示信息,
没有与此调用匹配的重载。
第 1 个重载(共 3 个),“(id: "dataStore", options: Omit<DefineStoreOptions<"dataStore", { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }, {}, { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }>, "id">): StoreDefinition<...>”,出现以下错误。
类型“{ persist: { enabled: boolean; strategies: { storage: Storage; paths: string[]; }[]; }; state: () => { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }; actions: { ...; }; getters: {}; }”的参数不能赋给类型“Omit<DefineStoreOptions<"dataStore", { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }, {}, { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }>, "id">”的参数。
对象字面量只能指定已知属性,并且“persist”不在类型“Omit<DefineStoreOptions<"dataStore", { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }, {}, { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }>, "id">”中。
第 2 个重载(共 3 个),“(id: "dataStore", storeSetup: () => unknown, options?: DefineSetupStoreOptions<"dataStore", _UnwrapAll<Pick<unknown, never>>, Pick<unknown, never>, Pick<unknown, never>> | undefined): StoreDefinition<...>”,出现以下错误。
类型“{ persist: { enabled: boolean; strategies: { storage: Storage; paths: string[]; }[]; }; state: () => { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }; actions: { ...; }; getters: {}; }”的参数不能赋给类型“() => unknown”的参数。
对象字面量只能指定已知属性,并且“persist”不在类型“() => unknown”中。ts(2769)
(property) persist: {
enabled: boolean;
strategies: {
storage: Storage;
paths: string[];
}[];
}
下面是将里面的代码部分注释掉了,还是会报这个错误的情况**
没有与此调用匹配的重载。
第 1 个重载(共 3 个),“(id: "dataStore", options: Omit<DefineStoreOptions<"dataStore", { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }, {}, { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }>, "id">): StoreDefinition<...>”,出现以下错误。
类型“{ persist: {}; state: () => { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }; actions: { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }; getters: {}; }”的参数不能赋给类型“Omit<DefineStoreOptions<"dataStore", { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }, {}, { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }>, "id">”的参数。
对象字面量只能指定已知属性,并且“persist”不在类型“Omit<DefineStoreOptions<"dataStore", { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }, {}, { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }>, "id">”中。
第 2 个重载(共 3 个),“(id: "dataStore", storeSetup: () => unknown, options?: DefineSetupStoreOptions<"dataStore", _UnwrapAll<Pick<unknown, never>>, Pick<unknown, never>, Pick<unknown, never>> | undefined): StoreDefinition<...>”,出现以下错误。
类型“{ persist: {}; state: () => { xiaohu: string; userinfo: {}; asideWidth: string; tabList: { path: string; title: string; }[]; activeTab: string; }; actions: { handleAsideWidth(): void; getDefault(route: string): void; addTabs(tab: any): void; }; getters: {}; }”的参数不能赋给类型“() => unknown”的参数。
对象字面量只能指定已知属性,并且“persist”不在类型“() => unknown”中。ts(2769)
成功了!
时隔多日,突然又看到了有人回复我这个问题,然后把持久化插件(pinia-plugin-persist)卸载了,配置也删了,安装了pinia-plugin-persistedstate,这个插件配置好,就可以了。下面是没有报错,并且打包成功的截图!!!
非常感谢各位的帮助!!!
回复
1个回答
test
2024-06-29
回复
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容