数据加载

# 懒加载

v-as-lazyload表示懒加载指令。代码如下:

<template>
  <div class="t-lazyload-area">
    <div v-for="(graph,index) in graphs" :key="'t-lazyload-area-'+index">
      <div>
        <img  v-as-lazyload="getImageUrl(graph)"/>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "t-lazyload",
  data() {
    return {
      graphs: [
        "filled-circle",
        "filled-square",
        "filled-top-equilateral",
        "filled-bottom-equilateral",
        "filled-left-top-isosceles-right-triangle",
        "filled-right-top-isosceles-right-triangle",
        "filled-left-bottom-isosceles-right-triangle",
        "filled-right-bottom-isosceles-right-triangle",
        "filled-diamond",
        "filled-four-pointed-star",
        "filled-pentagon",
        "filled-five-pointed-star",
        "filled-hexagon",
        "filled-six-pointed-star",
        "filled-octagon",
        "filled-rectangle",
        "filled-circle-rectangle",
        "filled-ordinary-diamond",
        "filled-elliptic"
      ],
    }
  },
  computed:{
    getImageUrl(){
      return function (img){
        return require(`../images/${img}.png`)
      }
    }
  }
}
</script>

<style>
.t-lazyload-area{
  width: 100%;
  height: 500px;
  overflow-y: auto;
}
.t-lazyload-area div{
  width: 100%;
  height: 100px;
}
.t-lazyload-area>div>div{
  width: 80px;
  height: 80px;
  border: 1px solid #E4E7ED;
  border-radius: 10px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.t-lazyload-area>div>img {
  width: 70px;
  height: 70px;
}
</style>
Expand Copy

# 触底加载

v-as-loadmore表示触底加载指令,代码如下:

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
88
89
90
91
92
93
94
95
96
97
98
99
100
<template>
  <div v-as-loadmore="loadmore" class="t-loadmore-area">
    <div v-for="(item,index) in 100">
      {{item}}
    </div>
  </div>
</template>

<script>

export default {
  name: "t-loadmore",
  data(){
    return{

    }
  },
  methods:{
    loadmore(){
      alert("已经触底,需要加载新数据")
    }
  },
}
</script>

<style>
.t-loadmore-area{
  width: 100%;
  height: 500px;
  overflow-y: auto;
  box-sizing: border-box;
}
.t-loadmore-area>div{
  margin-left: 3%;
  width: 94%;
  height: 30px;
  line-height: 30px;
}
</style>
Expand Copy

# 触底加载(对el-table元素)

用v-as-loadmore-el-table表示触底加载指令(对el-table元素),示例与上面类似。