【发布时间】:2016-11-20 07:54:46
【问题描述】:
我在运行我的 Angular 2 应用程序时遇到错误,这是我的 app.js
import 'zone.js/lib/browser/zone-microtask';
import 'reflect-metadata';
import { Component, View, bootstrap } from 'angular2/angular2';
import { HelloComponent } from './hello.component';
@Component({
selector: 'hello-app'
})
@View({
directives: [HelloComponent],
template: `
<div>
<hello-component></hello-component>
</div>
`
})
class HelloApp { }
bootstrap(HelloApp, []);
这是错误:
{ [SyntaxError: /code/angular2-example/app.js: Unexpected token (7:0) 解析文件时:/code/angular2-example/app.js] pos: 190, loc: 位置 { line: 7, column: 0 }, _babel: true, codeFrame: '\u001b[0m 5 | \u001b[36m进口\u001b[39m \u001b[32m{\u001b[39m HelloComponent \u001b[32m}\u001b[39m 从 \u001b[31m\'./hello.component\'\u001b[39m\u001b[1m;\u001b[22m\n 6 | \n> 7 | \u001b[7m@\u001b[27m组件\u001b[34m\u001b[1m(\u001b[22m\u001b[39m\u001b[32m{\u001b[39m\n | ^\n 8 |选择器\u001b[1m:\u001b[22m \u001b[31m\'hello-app\'\u001b[39m\n 9 | \u001b[32m}\u001b[39m\u001b[34m\u001b[1m]\u001b[22m\u001b[39m\n 10 | \u001b[7m@\u001b[27m查看\u001b[34m\u001b[1m(\u001b[22m\u001b[39m\u001b[32m{\u001b[39m\u001b[0m', 文件名:'code/angular2-example/app.js',
但我没看到。请你帮帮我。我只是从角度 2 开始。
【问题讨论】:
-
您使用的是哪个 Angular2 版本?
@View()几个月前被删除。还有来自zone-microtask和reflect-metadata的导入应该做什么? -
最新更新的进口清单见stackoverflow.com/a/34697758/5043867
标签: angular browserify babeljs