【问题标题】:Does Aurelia-Fetch have a dependency on whatwg-fetch?Aurelia-Fetch 是否依赖于 whatwg-fetch?
【发布时间】:2017-08-24 17:42:12
【问题描述】:

我正在尝试将我的 Aurelia 项目从测试版升级到三月版。

我遇到的错误之一是:

找不到名称“请求”。

在 GitHub 上搜索此问题:https://github.com/aurelia/fetch-client/issues/65

这个问题说“修复”是为whatwg-fetch 安装打字稿定义。当我安装这些打字稿定义时,错误就消失了。

但这是否意味着我也需要whatwg-fetch(查看我的 node_modules 文件夹,whatwg-fetch 未安装。)

【问题讨论】:

  • 如果您的目标环境原生支持 fetch API,则无需使用whatwg-fetch

标签: javascript typescript npm aurelia fetch-api


【解决方案1】:

aurelia-fetch-client 封装了 Fetch APIwahtwg-fetch 是一个 Fetch polyfill,因此 fetch 客户端依赖于 polyfill 是没有意义的。此外,您将使用哪个 polyfill 取决于您使用的模块加载器。

基于 JSPM/SystemJS 的应用使用来自 GitHub 的 fetch polyfill,而大多数其他模块加载器使用 whatwg-fetch

所以是的,您需要安装 whatwg-fetch,但有充分的理由说明为什么 aurelia-fetch-client 不依赖它。

【讨论】:

  • 很好的答案!谢谢!
  • 对不起,我不清楚这个答案。这是否是说如果我们使用 SystemJS,我们需要 GitHub fetch,否则我们需要 whatwg-fetch
  • 据我目前所知,是的。
猜你喜欢
  • 2018-03-13
  • 2016-10-13
  • 2020-03-10
  • 1970-01-01
  • 1970-01-01
  • 2016-03-12
  • 2023-03-04
  • 2017-12-17
相关资源
最近更新 更多