Javascript 简单角度2应用程序给出;可能未经处理的拒绝”;错误
我有一个非常基本的例子: index.html:Javascript 简单角度2应用程序给出;可能未经处理的拒绝”;错误,javascript,angular,Javascript,Angular,我有一个非常基本的例子: index.html: <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>FlyLeaf</title> <script src="js/lib/system.js"></script> <script src="js/lib/
<!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>
我看到它在plunker上工作,但在本地它没有…:(
(在Firefox和Chrome上)我看到的错误是,您缺少了可以使用注释的内容 因此,将其添加到您的HTML中(请参见下面的文档中添加的内容) 最后,作为建议,使用System.import如下
System.import("your.app").catch(console.log.bind(console));
有了这个,您将能够捕获更多的错误
试试看,你应该很乐意去做。是的,在添加了加载traceur和配置选项之后——然后它运行了:)(尽管它有语法错误,对于app.js的第一行——“import{Composer…”。但它正在工作…:D…)现在语法错误消失了。我所做的是下载了四个文件——angular2.dev.js(来自#32)、system.js、traceur-runtime.js和es6模块-loader@0.16.6.js-在“lib”文件夹中,让HTML从那里加载它们,现在一切都好了-我在本地有所有必要的东西,我的代码正在工作:)。。。
"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)"
<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.import("your.app").catch(console.log.bind(console));