当我try 将bootstrap添加到我的Angular 项目时,我得到了这个错误:
MainComponent类是独立组件,不能 在@NgModule.bootstrap数组中使用.使用 bootstrap 应用程序 函数改为用于 bootstrap
完全在app.module文件中
bootstrap:[MainComponent] }) export class AppModule { }
个
如何修复此错误以便在我的应用程序中使用Bootstrap,提前谢谢
当我try 将bootstrap添加到我的Angular 项目时,我得到了这个错误:
MainComponent类是独立组件,不能 在@NgModule.bootstrap数组中使用.使用 bootstrap 应用程序 函数改为用于 bootstrap
完全在app.module文件中
bootstrap:[MainComponent] }) export class AppModule { }
个
如何修复此错误以便在我的应用程序中使用Bootstrap,提前谢谢
看起来你把stangone和ngModule都混在一起了. 如果您希望使用单机版(不带ngModule),则需要在Main中使用bootstrapApplication(MainComponent).
第二种 Select 是使用ngModule并删除MainComponent中的Standonly:True属性
@Component({
selector: 'app-main',
// standalone: true, // remove this !!!!
templateUrl: './main.component.html',
styleUrls: ['./main.component.css']
})
export class MainComponent {
// ...
}