• Badge徽标数
    • 规则
  • 代码演示
  • API

    Badge徽标数

    图标右上角的红点、数字或者文字。用于告知用户,该区域的状态变化或者待处理任务的数量。

    规则

    • 当用户只需知道大致有内容更新时,应该使用红点型,如:社交中的群消息通知。
    • 当用户有必要知晓每条更新时,应该使用数字型。如:社交中的一对一的消息通知。

    代码演示

    基本用法

    最简单的用法。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'demo-badge-basic',
    4. template: `
    5. <List [renderHeader]=(renderHeader)>
    6. <ListItem [extra]="'extra content'" [arrow]="'horizontal'">
    7. <Badge [dot]="true" [text]="77" class="dot-badge">
    8. <span style="width:26px ; height: 26px; background:#ddd; display:inline-block"></span>
    9. </Badge>
    10. <span style="margin-left:12px">Dot badge</span>
    11. </ListItem>
    12. <ListItem [thumb]="'https://zos.alipayobjects.com/rmsportal/faMhXAxhCzLvveJ.png'"
    13. [extra]="customBadage" [arrow]="'horizontal'">Content
    14. </ListItem>
    15. <ListItem>
    16. <Badge [text]="'促'" [corner]="true">
    17. <div class="corner-badge">Use corner prop</div>
    18. </Badge>
    19. </ListItem>
    20. <ListItem [className]="'special-badge'" [extra]="customSpecialBadage">
    21. Custom corner
    22. </ListItem>
    23. <ListItem [extra]="'extra'" [arrow]="'horizontal'">
    24. <Badge [text]="0">Text number 0</Badge>
    25. <Badge [text]="'new'" style="margin-left:12px;"></Badge>
    26. </ListItem>
    27. <ListItem >
    28. Marketing:
    29. <Badge [text]="'减'" [hot]="true" style="margin-left:12px;"></Badge>
    30. <Badge [text]="'惠'" [hot]="true" style="margin-left:12px;"></Badge>
    31. <Badge [text]="'免'" [hot]="true" style="margin-left:12px;"></Badge>
    32. <Badge [text]="'反'" [hot]="true" style="margin-left:12px;"></Badge>
    33. <Badge [text]="'HOT'" [hot]="true" style="margin-left:12px;"></Badge>
    34. </ListItem>
    35. <ListItem >
    36. Customize
    37. <Badge class="quan" [text]="'券'" [setStyle]="quanStyle"></Badge>
    38. <Badge class="new" [text]="'NEW'" [setStyle]="newStyle"></Badge>
    39. <Badge class="autopay" [text]="'自动缴费'" [setStyle]="autopayStyle"></Badge>
    40. </ListItem>
    41. </List>
    42. <ng-template #customBadage>
    43. <Badge [text]="77" [overflowCount]="55"></Badge>
    44. </ng-template>
    45. <ng-template #customSpecialBadage>
    46. <Badge [text]="'促'" [size]="'large'"></Badge>
    47. </ng-template>
    48. `,
    49. styles: [
    50. `
    51. /deep/ .dot-badge .am-badge-dot{
    52. right:-8px;
    53. }
    54. .corner-badge {
    55. height: 50px;
    56. width: 200px;
    57. text-align: left;
    58. font-size: 17px;
    59. color: #000;
    60. }
    61. /deep/ .special-badge .am-list-line {
    62. padding-right: 0;
    63. }
    64. /deep/ .special-badge .am-list-line .am-list-extra {
    65. padding: 0;
    66. height: 44px;
    67. }
    68. /deep/ .special-badge .am-badge {
    69. transform: rotate(45deg);
    70. transform-origin: right bottom;
    71. right: 0px;
    72. top: 13px;
    73. width: 50px;
    74. }
    75. /deep/ .special-badge .am-badge-text {
    76. border-radius: 1px;
    77. }
    78. /deep/ .am-badge {
    79. text-align: right;
    80. font-size: 17px;
    81. color: #000;
    82. }
    83. `
    84. ]
    85. })
    86. export class DemoBadgeBasicComponent {
    87. quanStyle = {
    88. 'margin-left': '12px',
    89. padding: '0 3px',
    90. 'background-color': '#f19736',
    91. 'border-radius': '2px'
    92. };
    93. newStyle = {
    94. 'margin-left': '12px',
    95. padding: '0 3px',
    96. 'background-color': '#21b68a',
    97. 'border-radius': '2px'
    98. };
    99. autopayStyle = {
    100. 'margin-left': '12px',
    101. padding: '0 3px',
    102. 'background-color': '#fff',
    103. 'border-radius': '2px',
    104. color: '#f19736',
    105. border: '1px solid #f19736'
    106. };
    107. renderHeader() {
    108. return 'Basic';
    109. }
    110. }

    Badge 徽标数 - 图1

    API

    属性说明类型默认值
    size大小,可选 largesmallstringsmall
    text展示的数字或文案,当为数字时候,大于 overflowCount 时显示为 ${overflowCount}+,为 0 时隐藏string|number-
    corner置于角落booleanfalse
    dot不展示数字,只有一个小红点booleanfalse
    overflowCount展示封顶的数字值number99
    hot营销样式booleanfalse