gpt4 book ai didi

Angular 2 : Property 'toPromise' does not exist on type 'Observable'

转载 作者:行者123 更新时间:2023-12-02 15:19:04 29 4
gpt4 key购买 nike

我正在开发 Angular 2 项目并关注 Http Client Guide用于实现 HTTP 请求但是在使用 RsJx 模块时收到以下错误。

Property 'toPromise' does not exist on type 'Observable'

我已完成以下操作,但错误仍然存​​在:

  • 向服务模块添加了import 'rxjs/add/operator/toPromise';
  • 检查了 RxJs 库的版本是否存在任何依赖关系。
  • RxJs 库导入所有模块

你可以找到我的源代码here在 Github 上。请指导我应该做什么以及我缺少什么。谢谢。

您可以在 rxjs-operators.ts 文件中找到所有导入,我在 app.component.ts 文件中引用了它以使其成为全局但我仍然是dragon.service.ts 文件有错误。 此外,.map() 也显示相同的错误

您可以在package.json 文件中找到所有版本详细信息。

其他详细信息是:

  • 节点版本:v4.4.7
  • npm 版本:v3.10.5
  • Angular 版本:2.0.0-rc.4
  • RxJs 版本:5.0.0-beta.6

注意: 目前我已经对代码进行了注释,但您可以根据需要进行修改。

最佳答案

请检查: Angular 2 2.0.0-rc.1 Property 'map' does not exist on type 'Observable<Response>' not the same as issue report

“对于 VS 2015(更新 3):

安装 VS 2015 Update 3 将 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js 替换为 https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518-U3/lib/typescriptServices.js 中的文件.不过,首先进行本地备份。”

此解决方法为我解决了“Property 'toPromise' does not exist”问题。

关于 Angular 2 : Property 'toPromise' does not exist on type 'Observable<Response>' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38607203/

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