Pagination分页器

分隔长列表,每次只加载一个页面。

规则

  • 当加载/渲染所有数据将花费很多时间或者流量时使用

代码演示

基本用法

基本的分页器。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'demo-pagination-basic',
  4. template: `
  5. <div class="pagination-container">
  6. <p class="sub-title">Button with text</p>
  7. <Pagination [total]="5" [current]="1" [locale]="locale"></Pagination>
  8. <p class="sub-title">Button with text and icon</p>
  9. <Pagination class="custom-pagination-with-icon"
  10. [total]="5"
  11. [current]="1"
  12. [locale]="{prevText:localeLeft,nextText:localeRight}">
  13. </Pagination>
  14. <p class="sub-title">Hide number</p>
  15. <Pagination [simple]="true" [total]="5" [current]="1" [locale]="locale"></Pagination>
  16. <p class="sub-title">Show number only</p>
  17. <Pagination [mode]="'number'" [total]="5" [current]="3"></Pagination>
  18. <p class="sub-title">Point style</p>
  19. <Pagination [mode]="'pointer'" [total]="5" [current]="2" style="marginBottom: '16px'"></Pagination>
  20. <ng-template #localeLeft>
  21. <span class="arrow-align"><Icon type="left"></Icon>上一步</span>
  22. </ng-template>
  23. <ng-template #localeRight>
  24. <span class="arrow-align">下一步<Icon type="right"></Icon></span>
  25. </ng-template>
  26. </div>
  27. `,
  28. styles: [
  29. `
  30. .pagination-container {
  31. margin: 0 15px;
  32. }
  33. .custom-pagination-with-icon .am-pagination-wrap-btn-prev .am-button-inline {
  34. padding-left: 0;
  35. padding-right: 10px;
  36. }
  37. .custom-pagination-with-icon .am-pagination-wrap-btn-next .am-button-inline {
  38. padding-left: 10px;
  39. padding-right: 0;
  40. }
  41. .arrow-align {
  42. display: flex;
  43. align-items: center;
  44. }
  45. .sub-title {
  46. color: #888;
  47. font-size: 14px;
  48. padding: 30px 0 18px 0;
  49. }
  50. `
  51. ]
  52. })
  53. export class DemoPaginationBasicComponent {
  54. locale = {
  55. prevText: 'Prev',
  56. nextText: 'Next'
  57. };
  58. constructor() {}
  59. }

Pagination 分页器 - 图1

API

属性说明类型默认值
mode形态,可选button,number,pointerstringbutton
current当前页号number1
total数据总数number0
simple是否隐藏数值booleanfalse
disabled禁用状态booleanfalse
locale国际化, 可以覆盖全局LocaleProvider的配置Object:{prevText, nextText}
onChangechange 事件触发的回调函数(e: Object): void