• Button按钮
    • 代码演示
    • API

    Button按钮

    点击后会触发一个操作。

    代码演示

    基本用法

    最简单的用法。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'demo-button-basic',
    4. template: `
    5. <WingBlank>
    6. <div Button [type]="'dashed'" (onClick)="onClick()">dashed</div>
    7. <WhiteSpace ></WhiteSpace>
    8. <div Button (onClick)="onClick()">default</div>
    9. <WhiteSpace ></WhiteSpace>
    10. <div Button [disabled]="true">default diasbled</div>
    11. <WhiteSpace ></WhiteSpace>
    12. <div Button [type]="'primary'">primary</div>
    13. <WhiteSpace ></WhiteSpace>
    14. <div Button [type]="'primary'" [disabled]="true">primary diasbled</div>
    15. <WhiteSpace ></WhiteSpace>
    16. <div Button [type]="'warning'">warning</div>
    17. <WhiteSpace ></WhiteSpace>
    18. <div Button [type]="'warning'" [disabled]="true">warning</div>
    19. <WhiteSpace ></WhiteSpace>
    20. <div Button [loading]="true" >loading</div>
    21. <WhiteSpace ></WhiteSpace>
    22. <div Button [icon]="'check-circle-o'">with icon</div>
    23. <WhiteSpace ></WhiteSpace>
    24. <div Button [icon]="img">
    25. with custom icon
    26. </div>
    27. <ng-template #img>
    28. <img src="https://gw.alipayobjects.com/zos/rmsportal/jBfVSpDwPbitsABtDDlB.svg" alt="" />
    29. </ng-template>
    30. <WhiteSpace ></WhiteSpace>
    31. <div Button style="margin-right: 4px" [type]="'primary'" [inline]="true">inline primary</div>
    32. <div Button [type]="'ghost'" [inline]="true">inline ghost</div>
    33. <WhiteSpace ></WhiteSpace>
    34. <div Button style="margin-right: 4px" [type]="'primary'" [inline]="true" [size]="'small'">primary</div>
    35. <div Button [type]="'primary'" [inline]="true" [disabled]="true" [size]="'small'">primary diasbled</div>
    36. <WhiteSpace ></WhiteSpace>
    37. <div Button style="margin-right: 4px" [type]="'ghost'" [inline]="true" [size]="'small'">ghost</div>
    38. <div Button [type]="'ghost'" [inline]="true" [disabled]="true" [size]="'small'">ghost diasbled</div>
    39. </WingBlank>
    40. <List className="my-list">
    41. <ListItem [extra]="ghost" [arrow]="'horizontal'">Regional manager
    42. <Brief>Can be collected, refund, discount management, view data and other operations</Brief>
    43. </ListItem>
    44. <ListItem [extra]="primary" [arrow]="'horizontal'">Regional manager
    45. <Brief>Can be collected, refund, discount management, view data and other operations</Brief>
    46. </ListItem>
    47. </List>
    48. <ng-template #ghost>
    49. <div Button [type]="'ghost'" [inline]="true" style="margin-right: 4px" [size]="'small'">small</div>
    50. </ng-template>
    51. <ng-template #primary>
    52. <div Button [type]="'primary'" [inline]="true" style="margin-right: 4px" [size]="'small'">small</div>
    53. </ng-template>
    54. `
    55. })
    56. export class DemoButtonBasicComponent {
    57. onClick() {
    58. console.log('click');
    59. }
    60. }

    Button 按钮 - 图1

    API

    属性说明类型默认值
    type按钮类型,可选值为primary/ghost/warning或者不设string-
    size按钮大小,可选值为largesmallstringlarge
    disabled设置禁用booleanfalse
    onClick点击按钮的点击回调函数(e: Object): void
    style自定义样式Object
    inline是否设置为行内按钮booleanfalse
    loading设置按钮载入状态booleanfalse
    icon可以是 Icon 组件里内置的某个 icon 的 type 值,也可以是任意合法的 TemplateRef (注意: loading设置后此项设置失效)string/TemplateRef-