Javascript Angular2简单运行错误
嘿,在我的angular2应用程序中,我发现了这个错误:Javascript Angular2简单运行错误,javascript,angular,Javascript,Angular,嘿,在我的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({
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);
import{Component,View,bootstrap}来自'angular2';
@组成部分({
选择器:“我的应用程序”
})
@看法({
模板:“我的第一个Angular 2应用程序”
})
类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>
系统导入(“应用程序”);
试试:
从'angular2/angular2'导入{组件、视图、引导程序};
@组成部分({
选择器:“我的应用程序”
})
@看法({
模板:“我的第一个Angular 2应用程序”
})
类AppComponent{
}
bootstrap(AppComponent);
自angular2@2.0.0-beta.0导入上的名称空间已更改
import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
@Component({
selector: 'my-app'
})
@View({
template: '<h1>My first Angular 2 App</h1>'
})
class AppComponent {}
bootstrap(AppComponent);
您没有使用正确的
import
语句
将从angular2导入{Component,View,bootstrap}替换为
import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser'
查看官方Angular2快速备忘单参考:在app.js中将第一行从“Angular2/Angular2”更改为
import {Component, View, bootstrap} from 'angular2/angular2';
import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser'