我正在使用 1.8 版的 typescript 并收到此错误。我是 typescript 的新手,请帮忙。
npm 版本:3.9
文件:ponymain-app.component.ts
import {Component} from '@angular/core';
@Component({
selector: 'ponyracer-app',
template: `<h1>Hye bud!</h1>`
})
文件:Index.html
<body>
<ponyracer-app>
loading....
</ponyracer-app>
</body>
最佳答案
您需要将 @Component 装饰器直接附加到一个类,在您引导根组件之前您将一无所获
我假设你的主要根组件是 PonyComponent
这是你的代码的编辑版本
import { bootstrap } from '@angular/platform-browser-dynamic';
import {Component} from '@angular/core';
@Component({
selector: 'ponyracer-app',
template: `<h1>Hye bud!</h1>`
})
class PonyComponent { }
bootstrap( PonyComponent );
这是一个很好的开始资源:https://angular.io/docs/js/latest/quickstart.html
关于typescript - 预期的错误声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37745548/