loading 加载指示符·续3
延迟
延迟显示 loading 效果。当调用 open() 后 delay 时间内调用 close(),则不显示 loading 状态。
import { Component } from '@angular/core';import { LoadingService } from '@delon/abc/loading';@Component({ selector: 'components-loading-delay', template: ` <button nz-button (click)="show()">Display after 1 seconds</button> <button nz-button (click)="close()">Close</button> `,})export class ComponentsLoadingDelayComponent { constructor(private loadingSrv: LoadingService) {} show(): void { this.loadingSrv.open({ delay: 1000 }); setTimeout(() => this.loadingSrv.close(), 1000 * 5); } close() { this.loadingSrv.close(); }}
API
LoadingService
| open(options?: LoadingShowOptions) |
打开 |
|
|
LoadingShowOptions
| type |
显示类型 |
LoadingType |
spin |
✅ |
|
|
|
|
|
| icon |
类型为 icon 的配置项 |
LoadingIcon |
- |
✅ |
|
|
|
|
|
| custom |
类型为 custom 的配置项 |
LoadingCustom |
- |
✅ |
|
|
|
|
|
| delay |
延迟显示加载效果的时间(防止闪烁),单位:毫秒 |
number |
- |
✅ |
|
|
|
|
|