项目目录结构
项目目录结构图
说明
|-- 文件名
|-- 首层目录
|-- e2e
|-- node_modules
|-- src
|-- .editorconfig
|-- .gitignore
|-- angular.json
|-- browserslist
|-- karma.conf.js
|-- package-lock.json
|-- package.json
|-- README.md
|-- tsconfig.app.json
|-- tsconfig.json
|-- tsconfig.spec.json
|-- tslint.json
|-- src目录
|-- app
|-- assets
|-- environments
|-- favicon.ico
|-- index.html
|-- main.ts
|-- polyfills.ts
|-- karma.conf.js
|-- style.css
|-- test.ts
|-- app目录
|-- app-routing.module.ts
|-- app.component.css
|-- app.component.html
|-- app.component.spec.ts
|-- app.component.ts
|-- app.module.ts
|-- environments目录
|-- environments.prod.ts
|-- environments.ts
具体内容
.editorconfig
angular.json
|-- angular.json
|--首层目录
|--"$schema": ""
|--"version": 1,
|--"newProjectRoot": "projects",
|--"projects": {}
|--"defaultProject": "scrollable-tab"
|--"projects": {}
|--"scrollable-tab":{}
|--"projectType": "application",
|--"schematics": {},
|--"root": "",
|--"sourceRoot": "src",
|--"prefix": "app",
|--"architect": {}
|--"build": {}
|--"serve": {}
|--"extract-i18n": {}
|--"test": {}
|--"lint": {}
|--"e2e": {}
|--"builder": "@angular-devkit/build-angular:"
|--"options": {}
|--"configurations": {}
browserslist
// 只支持市场占有率>0.5%的浏览器
> 0.5%
last 2 versions
Firefox ESR
not dead
// 不支持IE 9-11
not IE 9-11 # For IE 9-11 support, remove 'not'.
package-lock.json&package.json
|-- package-lock.json
|--"name": "scrollable-tab",
|--"version": "0.0.0",
|--"lockfileVersion": 1,
|--"requires": true,
|--"dependencies"{}
|-- package.json
|--"name": "scrollable-tab",
|--"version": "0.0.0",
|--"scripts": {},
|--"ng": "ng",
|--"start": "ng serve",
|--"start.prod": "ng serve --aot",
|--"build": "ng build",
|--"test": "ng test",
|--"lint": "ng lint",
|--"e2e": "ng e2e",
|--"ivy": "ivy-ngcc"
|--"private": true,
|--"dependencies"{}
|--"@angular/animations": "~8.0.0",
|--"tslib": "^1.9.0",
|--"protractor": "5.4.0",
|--"devDependencies"{}
app-routing.module.ts // app路由
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [{
path : '',
component : HomeComponent
}];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
|--@NgModule元数据说明
|--declarations: []
|--providers: []
|--imports: []
|--exports: []
|--bootstrap: [AppComponent]
|--entryComponents: []
app.component.ts // app的组件
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {}
|--@Component元数据说明
|--继承于Directive装饰器
|--selector: string
|--inputs: string[]
|--outputsstring[]
|--providers: Provider[]
|--exportAs: string
|--queries: {[key: string]: any;}
|--host: {[key: string]: string;}
|--jit: true
|--自身的元数据
|--changeDetection: ChangeDetectionStrategy
|--viewProviders: Provider[]
|--moduleId: string
|--templateUrl/template: string
|--styleUrls/styles: string[]
|--animations: any[]
|--encapsulation: ViewEncapsulation
|--interpolation: [string, string]
|--entryComponents: Array<Type<any> | any[]>
|--preserveWhitespaces: boolean
app.module.ts // app的模块
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
HomeModule,
ScrollableTabModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }