错误:类型“可观察"上不存在属性“地图" [英] Error: Property 'map' does not exist on type 'Observable'

查看:129
本文介绍了错误:类型“可观察"上不存在属性“地图"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新angular/cli后,出现错误:

After I updated angular/cli, I got an error:

error TS2339: Property 'map' does not exist on type 'Observable<Response>'

我尝试了类型'Observable< Response>'上不存在属性'map'

但是错误仍然存​​在.

but still the error exists.

推荐答案

在提供代码而不是屏幕截图时,很容易发布答案. 无论如何,您必须pipe:

Its easy to post an answer when you provide your code instead of a screenshot. Anyhow, you have to pipe it:

getUsers() {
    return this._http.get(this.baseUrl+'/show-users', this.options)
                     .pipe(
                          map((response:Response)=>response.json())
                      );

记住要这样导入map:

import { map } from 'rxjs/operators';

这篇关于错误:类型“可观察"上不存在属性“地图"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆