【发布时间】:2019-05-08 08:05:00
【问题描述】:
我遇到的问题是,当我尝试使用 ionic serve 启动我的项目 (Ionic 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 函数出现新错误:
ERROR TypeError: Object(...) is not a function
如果您需要更多信息,请询问我会添加它!
【问题讨论】:
-
你是否可以导入
map或filter等运算符 -
没有。我需要它们吗?以及如何导入它们?
-
发布您的导入代码
-
你安装了什么 RxJS 版本?
npm ls --depth=0 -
@SachilaRanarawaka 添加了
标签: angular typescript ionic-framework rxjs