【问题标题】:Cannot load angular2 app correctly on Plunker无法在 Plunker 上正确加载 angular2 应用程序
【发布时间】:2016-05-25 16:13:27
【问题描述】:

Plunker 1 失败并出现以下错误:

zone.js:323 Error: Error: XHR error (404 Not Found) loading http://run.plnkr.co/XaKTrrlcPIlCBySj/node_modules/rxjs/index.js(…)

Plunker 2 因其他错误而失败:

angular2-polyfills.js:349 Error: Cannot read property 'prototype' of undefined(…)

我被困住了,不知道如何继续……有人可以帮忙吗?

【问题讨论】:

  • 您可以使用菜单 New > Angularjs 2.0.x (TS) 来获得一个工作的 Angular2 Plunker 模板。
  • @GünterZöchbauer 我认为 Plunker 2 已经使用了该模板......仍然无法成功运行......任何想法?

标签: typescript angular rxjs plunker


【解决方案1】:

您收到 HTTP 404 错误

The 404 or Not Found error message is a HTTP standard response code, in computer network communications, to indicate that the client was able to communicate with a given server, but the server could not find what was requested.

The web site hosting server will typically generate a "404 Not Found" web page when a user attempts to follow a broken or dead link; hence the 404 error is one of the most recognizable errors encountered on the World Wide Web.

所以基本上服务器无法找到资源“http://run.plnkr.co/XaKTrrlcPIlCBySj/node_modules/rxjs/index.js”。

由于服务器返回响应码,客户端无法解决此错误。

问候, 苏丹苏

【讨论】:

  • rxjs 包含在 bundle.js 中,但似乎在某个地方发出了类似 require('node_modules/rxjs/index.js') 的东西......不明白在哪里。
【解决方案2】:

例如,您需要将此配置用于 SystemJS:

map: {
  app: "./src",
  '@angular': 'https://npmcdn.com/@angular',
  'rxjs': 'https://npmcdn.com/rxjs@5.0.0-beta.6'
},

因为您的 plunkr 中没有 node_modules 文件夹...

将此 plunkr 视为示例:https://plnkr.co/edit/Qdm8GFsD5Rh1ioJV6jQM?p=info

这是 Angular 团队提供的 RC 版本模板:http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5?p=catalogue

【讨论】:

  • 我是从这个template开始的。 @angular/rxjs 包含在由 index.html 加载的 bundle.js 中。
  • 我也使用了你的模板,但我得到了一堆错误。 Plunker
  • 真的吗?也许您可以在创建问题时使用 Angular 团队提供的 RC 版本模板:plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5?p=catalogue
  • 我看了看,在我看来确实和 Plunker 2 样本一样。我非常确信带有 RxJS(最新)的 @angular RC 不能在 Plunker 上通过转译正确运行......
  • 区别在于SystemJS配置的map入口级别...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-20
  • 1970-01-01
  • 2013-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多