gpt4 book ai didi

javascript - ts 属性 'map' 在类型 'Observable' 上不存在

转载 作者:搜寻专家 更新时间:2023-10-30 21:20:04 24 4
gpt4 key购买 nike

<分区>

我是 angular 和 npm 的新手,但在学习时,我遇到了一个错误,代码似乎适用于我正在尝试重现的源代码(here)。

我认为这与我的开发环境有关,但我不明白为什么。

这是我的代码:

return this.http.get('api/cards.json')
.map((response:Response) => <Card[]>response.json().data)
.do(data=>console.log(data))
.catch(this.handleError);

.map 上,Visual Studio Code 给我这个错误:

ts Property 'map' does not exist on type 'Observable'

如果我忽略此错误并转到浏览器,我会收到相同的消息。

我已经使用 angular-cli 创建了我的项目,我的 angular-version 实际上是 2.4.4。服务器正在使用 ng serve 工具运行。

我做了一些搜索:

property map does not exist on observable response in angular --> 我不使用 visual studio 2015,而且,我的 Visual Studio Code 是最新的(而且这个错误似乎已经解决了一段时间)。

Angular 2 2.0.0-rc.1 Property 'map' does not exist on type 'Observable<Response>' not the same as issue report --> 我的命令行对 tsc 一无所知,在我完成 npm i typescript -g(并重新启动两个 VS codeng serve

知道出了什么问题(我想有些东西不是最新的,但我不知道更新什么以及如何更新)。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com