angular - 错误 TS2339 : Property 'do' does not exist on type 'Observable<

标签 angular angular-upgrade

尝试从 angular 5.2 升级到 angular 6.0.0,我们遇到了以下错误:

error TS2339: Property 'do' does not exist on type 'Observable<

任何想法为什么?

我们使用的代码是
return this.httpClient.post<x>(`${environment.apiUrl}auth/x/`,
  this.abcd,
  httpOptions)
  .do(x1 => this.subject.next(x1))

最佳答案

链操作符不久前被弃用,现在它们已被删除。使用可管道操作符,在本例中 tap替换 do .

import { tap } from 'rxjs/operators';

return this.httpClient.post(ˋ${environment.apiUrl}auth/x/ˋ, this.abcd, httpOptions)
.pipe(
    tap(x1 => this.subject.next(x1))
);

关于angular - 错误 TS2339 : Property 'do' does not exist on type 'Observable<,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50195209/

相关文章:

javascript - 以 Angular 将文本转换为html格式

angular - 在单元测试 Angular 时测试 scrollintoview

c# - 在 Angular 6 中传递带有空字符串的整数值时不调用 API Get 方法

angularjs - Angular NgUpgrade 将 AngularJS 服务注入(inject) Angular 服务;获取 : Unhandled Promise rejection: Cannot read property 'get' of undefined ; Zone:

angular - 使用哪个,Session、Cookies、服务器端数据?

angular - 验证页面上的选择元素

angularjs - 无法让 AngularJS 服务在 Angular 中运行

Angular 12 升级后样式问题

angularjs - 错误 : [$injector:unpr] Unknown provider - while migrating AngularJS1 to Angular6

angular - 从 angular4 升级到 angular 5 "test.ts is missing from the TypeScript compilation"后 npm 测试失败