我最近升级到了最新版本的@angular/fire,一切都运行良好。但是现在我已经迁移离开了兼容库,现在我遇到了这个问题。在下面的代码中,我遇到了以下错误:
Firebase:未创建Firebase应用程序“[DEFAULT]”-请调用Firebase App.initializeApp()
。// ...
import {getAuth, provideAuth} from '@angular/fire/auth';
import {getFirestore, provideFirestore} from '@angular/fire/firestore';
import {initializeApp, provideFirebaseApp} from '@angular/fire/app';
// ...
@NgModule({
// ...
providers: [
// ...
provideFirebaseApp(() => initializeApp(window['firebase_config'])),
provideFirestore(() => getFirestore()),
provideAuth(() => getAuth()),
// ...
],
// ...
})
export class ApModule {
// ...
}
以下是堆栈跟踪信息:
Error: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
at new ZoneAwareError (http://localhost:4200/vendor.js:65953:33)
at new FirebaseError (http://localhost:4200/apps_frontend_src_app_app_module_ts.js:166709:5)
at ErrorFactory.create (http://localhost:4200/apps_frontend_src_app_app_module_ts.js:166739:19)
at getApp (http://localhost:4200/apps_frontend_src_app_app_module_ts.js:122971:25)
at getAuth (http://localhost:4200/apps_frontend_src_app_app_module_ts.js:137360:77)
at http://localhost:4200/apps_frontend_src_app_app_module_ts.js:69140:44
at http://localhost:4200/apps_frontend_src_app_app_module_ts.js:69066:57
at ZoneDelegate.invoke (http://localhost:4200/polyfills.js:463:26)
at Zone.run (http://localhost:4200/polyfills.js:225:43)
at NgZone.runOutsideAngular (http://localhost:4200/vendor.js:34688:28)
at runOutsideAngular (http://localhost:4200/apps_frontend_src_app_app_module_ts.js:69066:33)
at http://localhost:4200/apps_frontend_src_app_app_module_ts.js:69140:17
at http://localhost:4200/apps_frontend_src_app_app_module_ts.js:1581:144
at http://localhost:4200/apps_frontend_src_app_app_module_ts.js:68430:47
at ZoneDelegate.invoke (http://localhost:4200/polyfills.js:463:26)
我完全不明白为什么会出现这个错误。非常感谢您的帮助!