pagination.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view>
  3. <uni-card is-full :is-shadow="false">
  4. <text class="uni-h6">分页器组件,用于展示页码、请求数据等</text>
  5. </uni-card>
  6. <uni-section title="默认样式" type="line" padding>
  7. <uni-pagination :total="50" title="标题文字" />
  8. </uni-section>
  9. <uni-section title="修改按钮文字" subTitle="使用 prev-text / next-text 属性修改按钮文字" type="line" padding>
  10. <uni-pagination :total="50" title="标题文字" prev-text="前一页" next-text="后一页" />
  11. </uni-section>
  12. <uni-section title="图标样式" subTitle="使用 show-icon 属性显示图标按钮" type="line" padding>
  13. <uni-pagination :show-icon="true" :total="50" title="标题文字" />
  14. </uni-section>
  15. <uni-section title="修改数据长度" type="line" padding>
  16. <uni-pagination :current="current" :total="total" title="标题文字" :show-icon="true" @change="change" />
  17. <view class="btn-view">
  18. <view>
  19. <text class="example-info">当前页:{{ current }},数据总量:{{ total }}条,每页数据:{{ pageSize }}</text>
  20. </view>
  21. <view class="btn-flex">
  22. <button class="button word-btn" hover-class="word-btn--hover" :hover-start-time="20"
  23. :hover-stay-time="70" @click="add"><text class="word-btn-white">增加10条数据</text></button>
  24. <button class="button" type="default" @click="reset">重置数据</button>
  25. </view>
  26. </view>
  27. </uni-section>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. components: {},
  33. data() {
  34. return {
  35. current: 1,
  36. total: 0,
  37. pageSize: 10
  38. }
  39. },
  40. methods: {
  41. add() {
  42. this.total += 10
  43. },
  44. reset() {
  45. this.total = 0
  46. this.current = 1
  47. },
  48. change(e) {
  49. console.log(e)
  50. this.current = e.current
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss" scoped>
  56. .example-body {
  57. /* #ifndef APP-NVUE */
  58. display: block;
  59. /* #endif */
  60. }
  61. .btn-view {
  62. /* #ifndef APP-NVUE */
  63. display: flex;
  64. flex-direction: column;
  65. /* #endif */
  66. padding: 15px;
  67. text-align: center;
  68. background-color: #fff;
  69. justify-content: center;
  70. align-items: center;
  71. }
  72. .btn-flex {
  73. display: flex;
  74. flex-direction: row;
  75. justify-content: center;
  76. align-items: center;
  77. }
  78. .button {
  79. margin: 20px;
  80. width: 150px;
  81. font-size: 14px;
  82. color: #333;
  83. }
  84. </style>