swiper-page.nvue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="uni-swiper-page">
  3. <list ref="list" class="list" :offset-accuracy="5" :bounce="false" fixFreezing="true">
  4. <cell v-for="(item, index) in dataList" :key="item.id" :ref="'item'+index">
  5. <view class="list-item">
  6. <text>{{item.name}}</text>
  7. </view>
  8. </cell>
  9. <cell class="loading"></cell>
  10. </list>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. pid: {
  17. type: [Number, String],
  18. default: ''
  19. },
  20. parentId: {
  21. type: String,
  22. default: ''
  23. }
  24. },
  25. data() {
  26. return {
  27. scrollable: true,
  28. dataList: []
  29. }
  30. },
  31. created() {
  32. for (var i = 0; i < 30; i++) {
  33. this.dataList.push({
  34. id: i,
  35. name: i
  36. });
  37. }
  38. },
  39. methods: {
  40. setScrollRef(height) {
  41. if (this.$refs['list'].setSpecialEffects) {
  42. this.$refs['list'].setSpecialEffects({
  43. id: this.parentId,
  44. headerHeight: height
  45. });
  46. }
  47. },
  48. loadData() {
  49. // 首次激活时被调用
  50. },
  51. clear() {
  52. // 释放数据时被调用,参考 swiper-list 缓存配置
  53. this.dataList.length = 0;
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped>
  59. .uni-swiper-page {
  60. flex: 1;
  61. position: absolute;
  62. left: 0;
  63. top: 0;
  64. right: 0;
  65. bottom: 0;
  66. }
  67. .list {
  68. flex: 1;
  69. background-color: #ebebeb;
  70. }
  71. .list-item {
  72. margin-left: 12px;
  73. margin-right: 12px;
  74. margin-top: 12px;
  75. padding: 20px;
  76. background-color: #fff;
  77. border-radius: 5px;
  78. }
  79. .loading {
  80. height: 20px;
  81. }
  82. </style>