angular - Rxjs ~6.4.0 in Angular 8. 地图问题
问题描述
我将我的应用程序更新到 Angular 8,并且有新版本的 rxjs ~6.4.0。现在我的 .map 功能不起作用,我在 VC 中有一个错误
“可观察”类型上不存在属性“地图”。
我尝试通过多种方式导入地图
import 'rxjs/add/operator/map';
或者这样
import { map } from 'rxjs/operators';
结果一样。下面的代码
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
const email = this.userInfo.email;
return this.routApi.checkUser(email).map(e => {
this.tradeOperService.writeOperRoomFromResponse(e);
return true;
}).catch((e) => {
if (e.error === 'traderoom') {
this.router.navigate(['registration']);
}
if (e.status === 500) {
this.authService.logout().subscribe(
suc => {
this.tokenService.deleteToken();
this.tradeOperService.deleteOperRoomInfo();
this.router.navigate(['login']);
},
err => {
this.OperRoomService.deleteOperRoomInfo();
this.tokenService.deleteToken();
}
);
}
return Observable.of(false);
});
错误如果在这里
return this.routApi.checkUser(email).map(e => {
代码末尾带有“of”的情况相同
return Observable.of(false);
解决方案
您现在需要使用管道链接运算符。改变这个:
return this.routApi.checkUser(email).map(e => {
到
return this.routApi.checkUser(email).pipe(
map(e => {
})
)
推荐阅读
- python - 出现此错误-__init__() 得到了一个意外的关键字参数“实例”
- python - 一对多关系 Django
- .net-core - 未找到配置文件“config.json”且不是可选的
- ruby-on-rails - Rails、Bootstrap 和枚举下拉列表 - 值未保存
- postgresql - POSTGIS ST_DISTANCE 函数和结果的问题
- indexing - Xtensor 返回值为 NaN 的索引
- nativescript - 用于 dev/qa/prod 环境策略的 Nativescript 不同的 api 端点
- java - 带有 IE 驱动程序的按钮和带有 Java 的 Xpath Selenium 的问题
- python - 使用 python 生成器进行 Alpha-beta 修剪
- database - 找不到数据库,并且 IFEXISTS=true,所以我们不能自动创建它”