TypeError: Array.from is not a function
TypeError: Array.from is not a function
我正在按照 Angular.io documenation 编写一个简单的 "Hello World" 应用 Angular 2. 一旦应用在浏览器中运行,Angular 2 从 angular2/src/browser_adapter.js
.
抛出一个 TypeError
一切似乎都设置正确。知道问题是什么吗?
控制台:
TypeError: Array.from is not a function
at createArrayFromMap (http://localhost:3000/node_modules/angular2/src/facade/collection.js:61:42)
at Function.MapWrapper.values (http://localhost:3000/node_modules/angular2/src/facade/collection.js:100:47)
at _createListOfBindings (http://localhost:3000/node_modules/angular2/src/di/injector.js:769:36)
at Function.Injector.resolve (http://localhost:3000/node_modules/angular2/src/di/injector.js:403:16)
at Function.Injector.resolveAndCreate (http://localhost:3000/node_modules/angular2/src/di/injector.js:420:41)
at _createAppInjector (http://localhost:3000/node_modules/angular2/src/core/application_common.js:291:39)
at http://localhost:3000/node_modules/angular2/src/core/application_common.js:257:31
at Zone.run (http://localhost:3000/node_modules/angular2/bundles/angular2.js:118:17)
at Zone.run (http://localhost:3000/node_modules/angular2/src/core/zone/ng_zone.js:165:42)
at NgZone.run (http://localhost:3000/node_modules/angular2/src/core/zone/ng_zone.js:112:40)BrowserDomAdapter.logError @ :3000/node_modules/angular2/src/dom/browser_adapter.js:71
all.babel.js(符合 es5 all.js):
import {Component, View, bootstrap} from 'angular2/angular2'
@Component({
selector: 'helloworld'
})
@View({
template: `<h1>Hello World!</h1>`
})
class HelloWorld {
}
bootstrap(HelloWorld)
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Angular 2 Hello World</title>
<script src="./node_modules/rx/dist/rx.all.js" charset="utf-8"></script>
<script src="./node_modules/systemjs/dist/system.js"></script>
<script src="./node_modules/angular2/bundles/angular2.js" charset="utf-8"></script>
<script src="./dist/all.js" charset="utf-8"></script>
</head>
<body>
<helloworld></helloworld>
<script type="text/javascript">
System.config({
baseURL: '/'
, defaultJSExtensions: true
, paths: {
'angular2/*': './node_modules/angular2/*.js' // Angular
, 'rx': './node_modules/rx/dist/rx.all.js'
, 'all': './dist/all.js'
}
})
System.import('all')
</script>
</body>
</html>
为了在浏览器中获得 Angular 2 到 运行,我必须包含 traceur 运行time:
<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
即使在我将 Systems.js 配置设置为使用 Babel 作为转译器之后,这也是必要的。
我正在按照 Angular.io documenation 编写一个简单的 "Hello World" 应用 Angular 2. 一旦应用在浏览器中运行,Angular 2 从 angular2/src/browser_adapter.js
.
TypeError
一切似乎都设置正确。知道问题是什么吗?
控制台:
TypeError: Array.from is not a function
at createArrayFromMap (http://localhost:3000/node_modules/angular2/src/facade/collection.js:61:42)
at Function.MapWrapper.values (http://localhost:3000/node_modules/angular2/src/facade/collection.js:100:47)
at _createListOfBindings (http://localhost:3000/node_modules/angular2/src/di/injector.js:769:36)
at Function.Injector.resolve (http://localhost:3000/node_modules/angular2/src/di/injector.js:403:16)
at Function.Injector.resolveAndCreate (http://localhost:3000/node_modules/angular2/src/di/injector.js:420:41)
at _createAppInjector (http://localhost:3000/node_modules/angular2/src/core/application_common.js:291:39)
at http://localhost:3000/node_modules/angular2/src/core/application_common.js:257:31
at Zone.run (http://localhost:3000/node_modules/angular2/bundles/angular2.js:118:17)
at Zone.run (http://localhost:3000/node_modules/angular2/src/core/zone/ng_zone.js:165:42)
at NgZone.run (http://localhost:3000/node_modules/angular2/src/core/zone/ng_zone.js:112:40)BrowserDomAdapter.logError @ :3000/node_modules/angular2/src/dom/browser_adapter.js:71
all.babel.js(符合 es5 all.js):
import {Component, View, bootstrap} from 'angular2/angular2'
@Component({
selector: 'helloworld'
})
@View({
template: `<h1>Hello World!</h1>`
})
class HelloWorld {
}
bootstrap(HelloWorld)
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Angular 2 Hello World</title>
<script src="./node_modules/rx/dist/rx.all.js" charset="utf-8"></script>
<script src="./node_modules/systemjs/dist/system.js"></script>
<script src="./node_modules/angular2/bundles/angular2.js" charset="utf-8"></script>
<script src="./dist/all.js" charset="utf-8"></script>
</head>
<body>
<helloworld></helloworld>
<script type="text/javascript">
System.config({
baseURL: '/'
, defaultJSExtensions: true
, paths: {
'angular2/*': './node_modules/angular2/*.js' // Angular
, 'rx': './node_modules/rx/dist/rx.all.js'
, 'all': './dist/all.js'
}
})
System.import('all')
</script>
</body>
</html>
为了在浏览器中获得 Angular 2 到 运行,我必须包含 traceur 运行time:
<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
即使在我将 Systems.js 配置设置为使用 Babel 作为转译器之后,这也是必要的。