我习惯用plattform-browser-dynamic 2.0.0导入bootstrap 像这样:
import { bootstrap } from '@angular/platform-browser-dynamic/';
现在我创建新的Projekt并使用角度释放2.2.0 Plattform-browser-dynamic软件包的版本为2.2.0:
"@angular/common": "~2.2.0",
"@angular/compiler": "~2.2.0",
"@angular/core": "~2.2.0",
"@angular/forms": "~2.2.0",
"@angular/http": "~2.2.0",
"@angular/platform-browser": "~2.2.0",
"@angular/platform-browser-dynamic": "~2.2.0",
"@angular/router": "~3.2.0",
"@angular/upgrade": "~2.2.0",
"angular-in-memory-web-api": "~0.1.15"
我尝试使用包2.0.0导入bootstrap,但是找不到它。 我的代码:
import { bootstrap } from '@angular/platform-browser-dynamic/*';
import {AppComponent} from "./app.component";
bootstrap(AppComponent);
ERROR:
错误TS2305:模块'" ../ node_modules / @ angular / platform-browser-dynamic / index"'没有导出的成员' bootstrap'。
我该如何解决?我找不到类似的lib。
答案 0 :(得分:5)
根据角度最终版本,您可以使用bootstrap
platformbrowser
方法bootstrapModule
您的应用模块。另外,您需要为您的应用程序创建自己的模块。
<强> 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 { }
<强> main.ts 强>
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);