简单的Angular 2应用程序给出了“可能未处理的拒绝”.错误
Simple Angular 2 app gives "Potentially unhandled rejection" error
我有这个非常基本的例子:
index . html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>FlyLeaf</title>
<script src="js/lib/system.js"></script>
<script src="js/lib/angular2.dev.js"></script>
</head>
<body>
<main-app></main-app>
<script>
System.config({
paths: {
'app.js': 'js/app.js'
}
});
System.import('app.js');
</script>
</body>
</html>
和inside app.js:
import {Component, View, bootstrap} from 'angular2/angular2';
@Component({
selector: 'main-app'
})
@View({
directives: [CSSClass, NgFor],
template: `
<h1>My first Angular 2 App</h1>
`
})
class MainApp {
constructor() {
this.footerLinks = [];
}
}
bootstrap(MainApp);
给了我这个错误:
"Potentially unhandled rejection [3] Error loading "app.js" at http://localhost/HelloWorld/js/app.js
http://localhost/HelloWorld/js/app.js:3:1: Unexpected token @ (WARNING: non-Error used)"
我看到它在一个活塞上工作,局部它不…(
(在Firefox &Chrome)
对于我所看到的错误,您缺少可以让您使用注释的跟踪器
所以把它添加到你的HTML中(见它甚至被添加到文档6下)。声明HTML)
<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
和在您的系统中。添加这些选项
System.config({
traceurOptions: {
annotations: true,
types: true,
memberVariables: true
},
//...
最后,作为建议,使用System。像这样导入
System.import("your.app").catch(console.log.bind(console));
这样你就可以捕获更多的错误。
试一试,你就可以走了
相关文章:
- 错误“;未处理'错误'事件“;在运行yo发电机之后
- NodeJS未处理的拒绝错误:Can't在发送标头后设置标头
- 如何处理错误'控制台未定义'在powershell中
- 可能未处理通过测试时出现错误
- 尝试在 Google 地图上映射点并收到错误(未处理的异常)
- 节点和续集的新手,并获得“未处理的拒绝类型错误:Vacation.create 不是一个函数”
- 角度 2 beta 即 10 “潜在未处理的拒绝 [3] 语法错误:预期”
- 承诺拒绝错误 - 未处理的拒绝错误:已关闭
- 运行Yeoman时发生未处理的错误事件
- d3.js + 动态 HTML - 第一个数据点未处理 &.append 附加到错误的位置
- gullow uglify的未处理错误事件
- React-React.render()上未处理的错误事件
- events.js:141投掷;//未处理'错误'事件
- 错误#2044:未处理的IOErrorEvent:.text=错误#2036:加载从未完成
- 未处理'错误'事件
- Node.js:某个时间的并行GET请求出现未处理的错误
- Node.js未处理'错误'事件
- event .js:72 throw er;//未处理'错误'事件
- NodeJs捕获异步方法中发生的未处理错误
- event .js:85 throw er;//未处理'错误'事件