详情;https://www.angular.cn/guide/component-overview
扩展:Angular component creator(生成文件)
扩展:Angular Files(生成文件+文件夹)建议
扩展:Angular Snippets (Version 11)建议
1-1 创建组件
ng g component <component-name>// ng g component components/MovieItem
Tips:每创建一个组件都会在app.module.ts文件中导入,注册
//app.module.tsimport { MovieItemComponent } from './components/movie-item/movie-item.component';@NgModule({/* 配置(声明)当前项目运行依赖的组件 */declarations: [AppComponent,MovieItemComponent],})
1-1-1 vscode插件创建组件
Angular FilesAngular Snippets
1-2 使用组件
// app.component.html<app-movie-item></app-movie-item>
1-4 wechat,vue,react,angular组件比较
wechat/AppApp.jsApp.wxmlApp.wxssApp.jsonVueApp.vue (html,css,js)ReactApp.js (html,js) import'./App.css'App.cssAngularMovieItem.component.htmlMovieItem.component.cssMovieItem.component.ts
