请问我怎么解决这个问题? Uncaught [DEFAULT]:Firebase:没有创建Firebase应用程序'[DEFAULT]' - 调用Firebase App.initializeApp()(app / no-app).V.hasOwnProperty.Object.defineProperty.value @polyfills.js:3e @ app.js:5t.ErrorFactory.o.value @ app.js:5o @ app.js:5e @ app.js:5u @ app.js:5(匿名函数)@ app.component.ts:11__webpack_require__ @ bootstrap ec8f9a1 ...:47(匿名函数)@src async:38__webpack_require__ @ bootstrap ec8f9a1 ...:47(匿名函数)@ setImmediate.js:186__webpack_require__ @ bootstrap ec8f9a1 ...:47(匿名函数)@ bootstrap ec8f9a1 ...:139(匿名函数)@bootstrap ec8f9a1 ...:139 ion-dev.js?v = 1.3.7:138 WebSocket已经处于CLOSING或CLOSED state.window.IonicDevServer.drainMessageQueue @ ion-dev.js?v = 1.3.7:138window.IonicDevServer.queueMessageSend @ ion-dev。 js?v = 1.3.7:130window.IonicDevServer.handleError @ ion-dev.js?v = 1.3.7:61window.onerror @ ion-dev.js?v = 1.3.7:41 polyfills.js:3未捕获的TypeError:非法调用enter image description here
的package.json
{
"name": "MyEventManager",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.0.2",
"@angular/compiler": "4.0.2",
"@angular/compiler-cli": "4.0.2",
"@angular/core": "4.0.2",
"@angular/forms": "4.0.2",
"@angular/http": "4.0.2",
"@angular/platform-browser": "4.0.2",
"@angular/platform-browser-dynamic": "4.0.2",
"@ionic-native/camera": "^3.6.1",
"@ionic-native/core": "3.6.1",
"@ionic-native/splash-screen": "3.6.1",
"@ionic-native/status-bar": "3.6.1",
"@ionic/storage": "2.0.1",
"cordova-plugin-camera": "^2.4.1",
"firebase": "^3.9.0",
"ionic-angular": "3.1.1",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.10"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.7",
"@ionic/cli-plugin-cordova": "1.0.0-rc.2",
"@ionic/cli-plugin-ionic-angular": "1.0.0-rc.2",
"typescript": "~2.2.1"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-camera": {}
}
}
}
app.component.ts
import { Component, NgZone } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import firebase from 'firebase';
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any;
zone:NgZone;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, zone:NgZone) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
firebase.initializeApp({
apiKey: "AIzaSyCWRv_TtIrZItQTqPTXR1Rm5QQYy7NNE8c",
authDomain: "geoentreprise.firebaseapp.com",
databaseURL: "https://geoentreprise.firebaseio.com",
storageBucket: "geoentreprise.appspot.com",
messagingSenderId: "653212172629"
});
//initialize the default app
/* var defaultApp = admin.initializeApp(defaultAppConfig);
console.log(defaultApp.name);
//retrieve services via the defaultApp variable...
var defaultAuth=defaultAuth.auth();
var defaultDatabase = defaultApp.database();
//or use the equivalent shorthand notation
defaultAuth = admin.auth();
defaultDatabase = admin.dabase();*/
this.zone = new NgZone({});
}
}
const unsubscribe = firebase.auth().onAuthStateChanged((user) => {
this.zone.run( () => {
if (!user) {
this.rootPage = 'login';
unsubscribe();
} else {
this.rootPage = HomePage;
unsubscribe();
}
});
});
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { Camera } from '@ionic-native/camera';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { AuthProvider } from '../providers/auth/auth';
import { EventProvider } from '../providers/event/event';
import { ProfileProvider } from '../providers/profile/profile';
class CameraMock {
getPicture(options){
return new Promise( (resolve, reject) => {
resolve(`TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=`);
});
}
}
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AuthProvider,
EventProvider,
ProfileProvider,
{provide: Camera, useClass: CameraMock}
]
})
export class AppModule {}