cl-loadmore.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="cl-loadmore__wrap">
  3. <cl-divider
  4. :background-color="backgroundColor"
  5. :color="color"
  6. :width="divider ? '400rpx' : '0rpx'"
  7. >
  8. <view class="cl-loadmore">
  9. <cl-loading
  10. :color="iconColor"
  11. :theme="loadingTheme"
  12. :size="20"
  13. v-if="!finish && loading"
  14. ></cl-loading>
  15. <text
  16. class="cl-loadmore__text"
  17. :style="{
  18. color,
  19. }"
  20. v-if="message"
  21. >{{ message }}</text
  22. >
  23. </view>
  24. </cl-divider>
  25. </view>
  26. </template>
  27. <script>
  28. /**
  29. * loadmore 加载更多
  30. * @description 加载更多
  31. * @tutorial https://docs.cool-js.com/uni/components/operate/loadmore.html
  32. * @property {Object} loading 是否加载中
  33. * @property {Boolean} finish 是否加载完成
  34. * @property {Boolean} divider 是否显示分割符,默认true
  35. * @property {String} color 字体颜色,默认#666
  36. * @property {String} iconColor 图标颜色
  37. * @property {String} backgroundColor 背景颜色,默认#f7f7f7
  38. * @property {String} text 普通状态下显示内容,默认“上拉加载更多”
  39. * @property {String} loadingText 加载中显示内容,默认“加载中”
  40. * @property {String} loadingTheme 加载图标主题
  41. * @property {String} finishText 加载完成显示内容,默认“没有更多了”
  42. * @example <cl-loadmore :loading="true" />
  43. */
  44. export default {
  45. name: "cl-loadmore",
  46. props: {
  47. // 是否加载中
  48. loading: Boolean,
  49. // 是否加载完成
  50. finish: Boolean,
  51. // 是否显示分割符
  52. divider: {
  53. type: Boolean,
  54. default: true,
  55. },
  56. // 字体颜色
  57. color: {
  58. type: String,
  59. default: "#666",
  60. },
  61. // 图标颜色
  62. iconColor: String,
  63. // 背景颜色
  64. backgroundColor: {
  65. type: String,
  66. default: "#f7f7f7",
  67. },
  68. // 普通状态下显示内容
  69. text: {
  70. type: String,
  71. default: "上拉加载更多",
  72. },
  73. // 加载中显示内容
  74. loadingText: {
  75. type: String,
  76. default: "加载中",
  77. },
  78. // 加载图标主题
  79. loadingTheme: String,
  80. // 加载完成显示内容
  81. finishText: {
  82. type: String,
  83. default: "没有更多了",
  84. },
  85. },
  86. computed: {
  87. message() {
  88. return this.finish ? this.finishText : this.loading ? this.loadingText : this.text;
  89. },
  90. },
  91. };
  92. </script>