Angular 图片回退项目教程
angular-img-fallbackUtility to work with loading images, has fallback-src to handle erros in image loading and loading-src for images loading placeholders项目地址:https://gitcode.com/gh_mirrors/an/angular-img-fallback
1. 项目的目录结构及介绍
angular-img-fallback/
├── README.md
├── package.json
├── src/
│ ├── app/
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── img-fallback.directive.ts
│ ├── assets/
│ ├── environments/
│ │ ├── environment.prod.ts
│ │ ├── environment.ts
│ ├── index.html
│ ├── main.ts
│ ├── styles.css
├── angular.json
├── tsconfig.json
- README.md: 项目说明文档。
- package.json: 项目依赖和脚本配置文件。
- src/: 源代码目录。
- app/: 应用模块目录。
- app.component.css: 主组件样式文件。
- app.component.html: 主组件模板文件。
- app.component.ts: 主组件逻辑文件。
- app.module.ts: 应用模块定义文件。
- img-fallback.directive.ts: 图片回退指令逻辑文件。
- assets/: 静态资源目录。
- environments/: 环境配置目录。
- environment.prod.ts: 生产环境配置文件。
- environment.ts: 开发环境配置文件。
- index.html: 应用入口HTML文件。
- main.ts: 应用入口逻辑文件。
- styles.css: 全局样式文件。
- angular.json: Angular CLI 配置文件。
- tsconfig.json: TypeScript 配置文件。
2. 项目的启动文件介绍
- main.ts: 这是Angular应用的入口文件。它负责引导应用模块(
AppModule
)并启动应用。
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));
3. 项目的配置文件介绍
- angular.json: 这是Angular CLI的配置文件,包含了项目的构建、开发服务器、测试等配置。
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-img-fallback": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular-img-fallback",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"bud
angular-img-fallbackUtility to work with loading images, has fallback-src to handle erros in image loading and loading-src for images loading placeholders项目地址:https://gitcode.com/gh_mirrors/an/angular-img-fallback