Angular Rxjs~6.4.0,角度8。地图问题

Angular Rxjs~6.4.0,角度8。地图问题,angular,rxjs,Angular,Rxjs,我将我的应用程序更新为Angular 8,并且有了rxjs~6.4.0的新版本。现在我的地图功能不起作用了,我在VC中犯了一个错误 类型“Observable”上不存在属性“map” 我尝试通过多种方式导入地图 import 'rxjs/add/operator/map'; 还是这样 import { map } from 'rxjs/operators'; 结果是一样的。 代码如下 canActivate(next: ActivatedRouteSnapshot, state: Route

我将我的应用程序更新为Angular 8,并且有了rxjs~6.4.0的新版本。现在我的地图功能不起作用了,我在VC中犯了一个错误

类型“Observable”上不存在属性“map”

我尝试通过多种方式导入地图

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);
});
与代码末尾的“of”相同的情况

return Observable.of(false);

现在需要使用“管道到链”操作符。更改此项:

return this.routApi.checkUser(email).map(e => {


您正在正确使用/导入它
从'rxjs/operators'导入{map}

您能否提供有关实施的详细信息

检查用户(电子邮件)

梅托德

如果它返回一个承诺,则使用from()使其可见

而正确的导入“of”的方法是


它需要按照此站点安装rxjs compat

,您可以尝试以下两个命令来尝试自动转换rxjs代码:npm(1)
install-g rxjs tslint
(2)
rxjs-5-to-6-migrate-p src/tsconfig.app.json
新版本需要进行大量更改(1)所有导入现在都来自
rxjs
rxjs/operators
(2)管道方法需要使用任何操作符(3)
Observable.of
现在只是
of
(4)
catch
现在是
catchError
checkUser(email:string):Observable{return this.http.get('api/user/check user/'+email);}它需要安装rxjs compat rxjs compat不是解决方案,这是一种解决方案,它会增加捆绑包的大小,并让您在应用程序中编写过时的、不推荐使用的代码。您应该使用版本6语法来正确执行。
return this.routApi.checkUser(email).map(e => {
return this.routApi.checkUser(email).pipe(
   map(e => {
   })
)
import { of } from 'rxjs';