• ActivityIndicator活动指示器
    • 规则
  • 代码演示
  • API
    • ActivityIndicator

    ActivityIndicator活动指示器

    活动指示器。表明某个任务正在进行中。

    规则

    • 不要让活动指示器静止,用户会以为该任务停滞了。
    • 在某些特定场景下,提供有意义的文案,帮助用户明白哪个任务正在进行中,eg:正在上传照片。
    • 如果能知道用户的等待时间,可以使用组件 Progress 来替代。

    代码演示

    基本用法

    最简单的用法。

    1. import { Component, OnDestroy } from '@angular/core';
    2. @Component({
    3. selector: 'demo-activity-indicator-basic',
    4. template: `
    5. <div class="am-wingblank am-wingblank-lg">
    6. <div class="loading-container">
    7. <p class="sub-title">Without text</p>
    8. <div class="loading-example">
    9. <ActivityIndicator [animating]="true"></ActivityIndicator>
    10. </div>
    11. <p class="sub-title">With text</p>
    12. <div class="loading-example">
    13. <ActivityIndicator [text]="'Loading...'"></ActivityIndicator>
    14. </div>
    15. <p class="sub-title">With large size and customized text style</p>
    16. <div class="loading-example">
    17. <div class="align">
    18. <ActivityIndicator [size]="'large'"></ActivityIndicator>
    19. <span style="margin-top:8;">Loading...</span>
    20. </div>
    21. </div>
    22. </div>
    23. <div class="toast-container">
    24. <div class="am-whitespace am-whitespace-xl"></div>
    25. <a role="button" class="am-button" (click)="showToast()"><span>click to show Toast</span></a>
    26. <div class="toast-example">
    27. <ActivityIndicator [toast]="true" [text]="'Loading...'" [animating]="animating"></ActivityIndicator>
    28. </div>
    29. </div>
    30. </div>
    31. `,
    32. styles: [
    33. `
    34. .sub-title {
    35. color: #888;
    36. font-size: 14px;
    37. padding: 30px 0 18px 0;
    38. }
    39. .am-wingblank .am-wingblank-lg {
    40. margin-left: 15px;
    41. margin-right: 15px;
    42. }
    43. .am-whitespace.am-whitespace-xl {
    44. height: 21px;
    45. }
    46. .am-wingblank {
    47. margin-left: 8px;
    48. margin-right: 8px;
    49. }
    50. .am-button {
    51. display: block;
    52. outline: 0 none;
    53. -webkit-appearance: none;
    54. -webkit-box-sizing: border-box;
    55. box-sizing: border-box;
    56. padding: 0;
    57. text-align: center;
    58. font-size: 18px;
    59. height: 47px;
    60. line-height: 47px;
    61. overflow: hidden;
    62. text-overflow: ellipsis;
    63. word-break: break-word;
    64. white-space: nowrap;
    65. color: #000;
    66. background-color: #fff;
    67. border: 1px solid #ddd;
    68. border-radius: 5px;
    69. margin: 0 15px 15px 15px;
    70. }
    71. `
    72. ]
    73. })
    74. export class DemoActivityIndicatorBasicComponent implements OnDestroy {
    75. animating = false;
    76. private _closeTimer;
    77. constructor() {}
    78. showToast() {
    79. this.animating = !this.animating;
    80. this._closeTimer = setTimeout(() => {
    81. this.animating = !this.animating;
    82. }, 1000);
    83. }
    84. ngOnDestroy() {
    85. clearTimeout(this._closeTimer);
    86. }
    87. }

    ActivityIndicator 活动指示器 - 图1

    API

    ActivityIndicator

    属性说明类型默认值
    animating显隐状态booleantrue
    sizespinner大小,可选small/largestringsmall
    toastloading样式类型booleanfalse
    textloading文本string-