我有一个问题,当我尝试使用ionic serve
启动我的项目(离子3)时总是会出现此错误
TypeError:无法设置未定义的属性'bindCallback'
我尝试了提及here on Github的内容。但是不知何故。
这是我的 package.json :
"dependencies": {
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
"@angular/platform-browser": "5.2.11",
"@angular/platform-browser-dynamic": "5.2.11",
"@ionic-native/admob-free": "^4.18.0",
"@ionic-native/core": "~4.17.0",
"@ionic-native/splash-screen": "~4.17.0",
"@ionic-native/status-bar": "~4.17.0",
"@ionic/storage": "2.2.0",
"@ultimate/ngxerrors": "^1.4.0",
"angularfire2": "^5.1.1",
"cordova-plugin-admob-free": "0.23.0",
"countup.js": "^1.9.3",
"countup.js-angular2": "^6.0.2",
"firebase": "^5.6.0",
"install": "^0.12.2",
"ionic-angular": "3.9.2",
"ionicons": "3.0.0",
"npm": "^5.4.1",
"rxjs": "^5.5.10",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.26"
},
"devDependencies": {
"@ionic/app-scripts": "3.2.1",
"typescript": "2.4.2"
},
这是我在所有文件中导入Observable的方式:
import { Observable } from 'rxjs/Observable';
这是关于我如何使用Observable的示例:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AngularFireFunctions } from 'angularfire2/functions';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class FirefunctionsProvider {
constructor(private afFun: AngularFireFunctions) {}
getShopItems() {
return Observable.create((observer) => {
this.afFun.httpsCallable('myfunction')({ text: 'Some Argument' })
.toPromise()
.then(resp => {
console.log({ resp });
})
.catch(err => {
console.error({ err });
});
});
}
}
编辑:
将import { Observable } from 'rxjs/Observable';
更改为import { Observable } from 'rxjs';
可行,但是现在我的firebase函数出现了新错误:
错误TypeError:Object(...)不是函数
如果您需要更多信息,请询问病态添加!
答案 0 :(得分:0)
我发布解决方案是因为拥有解决方案的人出于未知原因删除了答案:
我必须更改:
import { Observable } from 'rxjs/Observable';
到
import { Observable } from 'rxjs';
具有以下依赖性:
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3"