我是前端框架的新手,我正在学习Angular 2.在教程中,它告诉你包括这一行bootstrap(AppComponent).这个引导功能有什么作用?它只是启动应用程序的原因吗?我猜它与twitter-bootstrap UI框架无关.
bootstrap是告诉系统将页面上的组件渲染为主要组件的函数Angular2。
还通过指定应用程序的根来定义应用程序的实体点。
//basically array will have dependencies of shared component which will instantiate only once.
bootstrap(MyComponent, [SharedService, OtherComponent, ROUTING_DIRECTIVES]);
Run Code Online (Sandbox Code Playgroud)
但是,是的,您应该提到index.html页面上的组件选择器,例如
<my-component></my-component>
Run Code Online (Sandbox Code Playgroud)
如果将其与 Angular 1 进行比较,您会发现ng-app指令将angular.module名称作为输入ng-app="myApp",并为该应用程序提供这些模块组件或 angular.bootstrap在页面上启动应用程序的函数。