Blame view

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