gpt4 book ai didi

javascript - Angular2简单运行报错

转载 作者:行者123 更新时间:2023-11-29 19:23:20 25 4
gpt4 key购买 nike

嘿,在我的 angular2 应用程序中,我遇到了这个错误:

Potentially unhandled rejection [3] Error loading "app" at     http://localhost:8080/app.js

我用的是官方例子,代码如下:

app.js

 import {Component, View, bootstrap} from 'angular2';
@Component({
selector: 'my-app'
})
@View({
template: '<h1>My first Angular 2 App</h1>'
})
class AppComponent {
}
bootstrap(AppComponent);

index.html

 <!DOCTYPE html>
<html>
<head>
<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
<script src="https://jspm.io/system@0.16.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.dev.js"> </script>
</head>
<body>
<my-app></my-app>
<script>
System.import('app');
</script>
</body>
</html>

最佳答案

尝试:

import {Component, View, bootstrap} from 'angular2/angular2';
@Component({
selector: 'my-app'
})
@View({
template: '<h1>My first Angular 2 App</h1>'
})
class AppComponent {
}
bootstrap(AppComponent);

关于javascript - Angular2简单运行报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32094316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com