1. 起源
CDK是Component Dev kit的简称,首次提出是在2017年(PS:2017.07推出了可用的Beta版本),是Angular Material团队在开发Library时发现组件有很多相似的地方,最后进行了抽取,提炼出了公共的逻辑,这部分即是CDK,具体可以观看[2017年Angular Mix大会上的Jeremy Elbourn的介绍。
file-upload.component.html
1 | <div class="upload-container" |
2 | #uploadzone |
3 | dropzone |
4 | [class.hovering]="uploadzone.isHovering" |
5 | (hovered)="uploadzone.isHovering = $event" |
6 | (dropped)="onDrop($event)" |
7 | (click)="onClick()"> |
8 | <p class="icon"><mat-icon>cloud_upload</mat-icon></p> |
9 | <p class="title">Click or drag file to this area to upload</p> |
10 | <p class="desc">Support for a single or bulk upload. Strictly prohibit from uploading company data or other band files</p> |
11 | </div> |
12 | |
13 | <ul> |
14 | <li *ngFor="let file of files" [@fadeInOut]="file.state"> |
15 | <mat-progress-bar [value]="file.progress"></mat-progress-bar> |
16 | <span class="file-label"> |
17 | {{file.data.name}} |
18 | <a title="Retry" (click)="retryFile(file)" *ngIf="file.canRetry"> |
19 | <mat-icon>refresh</mat-icon></a> |
20 | <a title="Cancel" (click)="cancelFile(file)" *ngIf="file.canCancel"> |
21 | <mat-icon>cancel</mat-icon></a> |
22 | </span> |
23 | </li> |
24 | </ul> |
25 | |
26 | <input |
27 | type="file" |
28 | id="fileUpload" |
29 | name="fileUpload" |
30 | multiple="multiple" |
31 | accept="{{accept}}" |
32 | style="display:none;"/> |
file-upload.component.scss
渐进式Web应用程序(PWA)是一种Web应用程序,它提供了一组功能,可以为网站提供类似App的体验。
==特别提醒:以下是采用了angular/cli 9.1==
1 | // 终端命令 |
2 | ng add @angular/pwa |
3 | |
4 | |
5 | // 以下是输出信息 |
6 | localhost:d1 apple$ ng add @angular/pwa |
7 | Installing packages for tooling via npm. |
8 | Installed packages for tooling via npm. |
9 | CREATE ngsw-config.json (620 bytes) |
10 | CREATE src/manifest.webmanifest (1296 bytes) |
11 | CREATE src/assets/icons/icon-128x128.png (1253 bytes) |
12 | CREATE src/assets/icons/icon-144x144.png (1394 bytes) |
13 | CREATE src/assets/icons/icon-152x152.png (1427 bytes) |
14 | CREATE src/assets/icons/icon-192x192.png (1790 bytes) |
15 | CREATE src/assets/icons/icon-384x384.png (3557 bytes) |
16 | CREATE src/assets/icons/icon-512x512.png (5008 bytes) |
17 | CREATE src/assets/icons/icon-72x72.png (792 bytes) |
18 | CREATE src/assets/icons/icon-96x96.png (958 bytes) |
19 | UPDATE angular.json (3795 bytes) |
20 | UPDATE package.json (1319 bytes) |
21 | UPDATE src/app/app.module.ts (604 bytes) |
22 | UPDATE src/index.html (470 bytes) |
23 | ✔ Packages installed successfully. |
24 | localhost:d1 apple$ |