Angular Semantic UI 项目教程
1. 项目的目录结构及介绍
angular-semantic-ui/
├── e2e/
│ ├── src/
│ │ ├── app.e2e-spec.ts
│ │ └── app.po.ts
│ ├── protractor.conf.js
│ └── tsconfig.e2e.json
├── src/
│ ├── app/
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ └── app.module.ts
│ ├── assets/
│ ├── environments/
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── index.html
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── angular.json
├── package.json
├── tsconfig.json
└── tslint.json
目录结构介绍
-
e2e/: 端到端测试目录,包含测试脚本和配置文件。
- src/: 测试脚本文件。
- protractor.conf.js: Protractor 配置文件。
- tsconfig.e2e.json: TypeScript 配置文件。
-
src/: 源代码目录,包含应用程序的主要代码。
- app/: 应用程序模块和组件。
- assets/: 静态资源文件。
- environments/: 环境配置文件。
- index.html: 主页文件。
- main.ts: 应用程序入口文件。
- polyfills.ts: 浏览器兼容性填充文件。
- styles.css: 全局样式文件。
- test.ts: 测试配置文件。
- tsconfig.app.json: TypeScript 应用配置文件。
- tsconfig.spec.json: TypeScript 测试配置文件。
- tslint.json: TSLint 配置文件。
-
angular.json: Angular CLI 配置文件。
-
package.json: 项目依赖和脚本配置文件。
-
tsconfig.json: TypeScript 全局配置文件。
-
tslint.json: TSLint 全局配置文件。
2. 项目的启动文件介绍
main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
- main.ts 是 Angular 应用程序的入口文件。它负责启动应用程序并引导根模块
AppModule
。 - enableProdMode(): 在生产环境中启用生产模式。
- platformBrowserDynamic(): 使用 JIT 编译器动态引导应用程序。
- bootstrapModule(AppModule): 引导
AppModule
启动应用程序。
3. 项目的配置文件介绍
angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-semantic-ui": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular-semantic-ui",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",