index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <u-toast ref="uToast" />
  7. <u-loadmore :status="status" :loadText="loadText"
  8. :icon-type="iconType" :is-dot="isDot" @loadmore="loadmore"/>
  9. </view>
  10. </view>
  11. <view class="u-config-wrap">
  12. <view class="u-config-title u-border-bottom">
  13. 参数配置
  14. </view>
  15. <view class="u-config-item">
  16. <view class="u-item-title">模式选择</view>
  17. <u-subsection :current="current" :list="['加载前', '加载中', '加载后', '没有更多']" @change="statusChange"></u-subsection>
  18. </view>
  19. <view class="u-config-item">
  20. <view class="u-item-title">自定义提示语</view>
  21. <u-subsection current="1" :list="['是', '否']" @change="loadTextChange"></u-subsection>
  22. </view>
  23. <view class="u-config-item">
  24. <view class="u-item-title">加载中图标样式</view>
  25. <u-subsection :list="['circle', 'flower']" @change="styleChange"></u-subsection>
  26. </view>
  27. <view class="u-config-item">
  28. <view class="u-item-title">没有更多时用点替代</view>
  29. <u-subsection current="1" :list="['是', '否']" @change="isDotChange"></u-subsection>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. status: 'loadmore',
  39. iconType: 'circle',
  40. isDot: false,
  41. loadText: {
  42. loadmore: '点击或上拉加载更多',
  43. loading: '正在加载...',
  44. nomore: '没有更多了'
  45. },
  46. current: 0
  47. }
  48. },
  49. onReachBottom() {
  50. // 在此请求下一页
  51. },
  52. methods: {
  53. statusChange(index) {
  54. this.current = index;
  55. this.status = index == 0 ? 'loadmore' : index == 1 ? 'loading' : index == 2 ? 'loadmore' : 'nomore';
  56. },
  57. loadTextChange(index) {
  58. if(index == 0) {
  59. this.loadText = {
  60. loadmore: '用力往上拉',
  61. loading: '正在加载,请喝杯茶...',
  62. nomore: '我也是有底线的'
  63. }
  64. } else {
  65. this.loadText = {
  66. loadmore: '点击或上拉加载更多',
  67. loading: '正在加载...',
  68. nomore: '没有更多了'
  69. }
  70. }
  71. },
  72. styleChange(index) {
  73. this.current = 1;
  74. this.statusChange(1);
  75. this.iconType = index == 0 ? 'circle' : 'flower';
  76. },
  77. isDotChange(index) {
  78. this.current = 3;
  79. this.statusChange(3);
  80. this.isDot = index == 0 ? true : false;
  81. },
  82. // 点击组件,触发加载更多事件(status为'loadmore'状态下才触发)
  83. loadmore() {
  84. this.$refs.uToast.show({
  85. title: '点击触发加载更多',
  86. type: 'success'
  87. })
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .u-demo {}
  94. </style>