2
我有这个非常简单的例子:简单的角2的应用程序提供了 “可能未处理拒绝” 错误
的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>
和内部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)"
我看到了它的工作在plunker,并在本地也没有... :(
(两个火狐&铬)
是的,在加载traceur和config选项后 - 然后运行:)(它有语法错误,但对于app.js的第一行 - “import {Composer ...”。但它工作正常。 。:D ...) –
现在语法错误消失了。我所做的是我从“lib”文件夹中下载了四个文件 - angular2.dev.js(来自#32),system.js,traceur-runtime.js和[email protected],以及使HTML从那里加载它们,现在一切正常 - 我拥有本地所有必要的功能,并且我的代码正在工作:) ... –