Bra*_*sso 5 compiler-errors angular
Angular2 新手在这里。
我正在使用来自 Angular.io 的种子文件,但是当我运行“npm start”时,我收到了 tsc 编译器错误 -
tsc -p src/
src/app/app.module.ts(11,3): 错误 TS1146: 需要声明。
有人可以告诉我我缺少什么吗?我只有一个组件“AppComponent”。
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<h1>Hello</h1>
`,
})
export class AppComponent {
}
Run Code Online (Sandbox Code Playgroud)
和 index.html
<!DOCTYPE html>
<html>
<head>
<title>Angular QuickStart</title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-app>Loading AppComponent content here ...</my-app>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
对我来说一切看起来都很好,除了模板后面可能有一个额外的逗号......
应用程序组件.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<h1>Hello</h1>
`
})
export class AppComponent {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8986 次 |
| 最近记录: |