Error in Ionic project: Uncaught Error: Type Storage does not have 'ɵmod' property"

Error in Ionic project: Uncaught Error: Type Storage does not have 'ɵmod' property"

我在 Ionic 6.13.1 中开始了一个新项目。 所以,我添加了插件存储:

ionic cordova plugin add cordova-sqlite-storage

npm install --save @ionic/storage

app.module.ts中我写道:

import { IonicStorageModule } from '@ionic/storage';

IonicStorageModule 未被识别,只有 Storage 被识别。

当我在导入部分声明存储并且运行

离子发球

出现错误:“未捕获错误:类型存储没有'ɵmod'属性”。

我没有在代码中写任何其他行,只有这一行。

我该如何解决这个问题?谢谢

对于使用 Ionic 存储的基于 Angular 的 Ionic 应用程序,您必须使用存储-angular 库。

npm install @ionic/storage-angular

这里是 link Ionic Storage 文档以获取更多信息

我在搜索同样的问题,Rich Tillis 之前接受的答案是正确的,但对于像我这样的初学者来说可能不是很明显:

根据上面链接的 docs,您应该按如下方式在 app.module.ts 中进行导入:

注意:注意导入:@ionic/storage-angular 所以基本上一切都保持不变,除了进口。干得好离子 :)

import { IonicStorageModule } from '@ionic/storage-angular';

@NgModule({
  imports: [
    IonicStorageModule.forRoot()
  ]
})
export class AppModule { }