commit | author | age
|
aab811
|
1 |
<template> |
I |
2 |
<div> |
|
3 |
<div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" :infinite-scroll-distance="10"> |
|
4 |
<div v-for="temp in data"> |
|
5 |
<box5 v-bind="temp"></box5> |
|
6 |
</div> |
|
7 |
<div v-if="loading && !busy" class="demo-loading-container"> |
|
8 |
<a-spin /> |
|
9 |
</div> |
|
10 |
</div> |
|
11 |
<div style="position:fixed;bottom: 10px;" id="dddadf"> |
|
12 |
<a-pagination @change="onChange" :showQuickJumper="true" :size="size" v-model="current" |
|
13 |
:defaultPageSize="pageSize" :total="total" /> |
|
14 |
</div> |
|
15 |
<a-back-top> |
|
16 |
<a-icon type="up" />回到顶部 |
|
17 |
</a-back-top> |
|
18 |
</div> |
|
19 |
</template> |
|
20 |
<script> |
|
21 |
import infiniteScroll from 'vue-infinite-scroll'; |
|
22 |
import box5 from "../mini/box5-article.vue" |
|
23 |
import babyActicle from '../../assets/baby.htm' |
|
24 |
import shijie from '../../assets/shijie.htm' |
|
25 |
|
|
26 |
var obj1 = { |
|
27 |
"source": babyActicle, |
|
28 |
"title": "陈奕迅-Body Song 歌词", |
|
29 |
"read": 1101, |
|
30 |
"like": 233, |
|
31 |
"folder": "歌词", |
|
32 |
"publishTime": "2021-05-26", |
|
33 |
} |
|
34 |
var obj2 = { |
|
35 |
"source": shijie, |
|
36 |
"title": "这世界那么多人-吉他谱", |
|
37 |
"read": 3101, |
|
38 |
"like": 113, |
|
39 |
"folder": "吉他谱", |
|
40 |
"publishTime": "2020-05-26", |
|
41 |
} |
|
42 |
var obj3 = { |
|
43 |
"source": shijie, |
|
44 |
"title": "遥远的它-吉他谱", |
|
45 |
"read": 201, |
|
46 |
"like": 13, |
|
47 |
"folder": "吉他谱", |
|
48 |
"publishTime": "2022-07-26", |
|
49 |
} |
|
50 |
|
|
51 |
export default { |
|
52 |
components: { |
|
53 |
box5 |
|
54 |
}, |
|
55 |
directives: { |
|
56 |
infiniteScroll |
|
57 |
}, |
|
58 |
data() { |
|
59 |
return { |
|
60 |
|
|
61 |
data: [], |
|
62 |
loading: false, |
|
63 |
busy: false, |
|
64 |
size: "small", |
|
65 |
total: 500, |
|
66 |
pageSize: 20, |
|
67 |
current: 1, |
|
68 |
}; |
|
69 |
}, |
|
70 |
beforeMount() { |
|
71 |
this.data = [obj1, obj2,obj3]; |
|
72 |
}, |
|
73 |
methods: { |
|
74 |
onChange(current) { |
|
75 |
this.current = current; |
|
76 |
this.data = [obj2, obj3, obj1, obj2]; |
|
77 |
}, |
|
78 |
loadMore() { |
|
79 |
const data = this.data; |
|
80 |
this.loading = true; |
|
81 |
|
|
82 |
this.current += 1; |
|
83 |
console.log(this.current); |
|
84 |
console.log(this.busy); |
|
85 |
|
|
86 |
if (data.length > 15) { |
|
87 |
this.$message.warning('没有更多了'); |
|
88 |
this.busy = true; |
|
89 |
this.loading = false; |
|
90 |
return; |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
setTimeout(function() { |
|
95 |
this.loading = false; |
|
96 |
}, 1000); |
|
97 |
|
|
98 |
this.data = data.concat(obj1, obj3, obj2, obj3, obj1); |
|
99 |
|
|
100 |
}, |
|
101 |
}, |
|
102 |
}; |
|
103 |
</script> |
|
104 |
<style> |
|
105 |
/* .test { |
|
106 |
overflow: hidden; |
|
107 |
height: 700px; |
|
108 |
} |
|
109 |
|
|
110 |
.infinite-container { |
|
111 |
overflow: auto; |
|
112 |
} |
|
113 |
|
|
114 |
.infinite-container::-webkit-scrollbar { |
|
115 |
display: none; |
|
116 |
} */ |
|
117 |
|
|
118 |
.demo-loading-container { |
|
119 |
position: absolute; |
|
120 |
bottom: 40px; |
|
121 |
width: 100%; |
|
122 |
text-align: center; |
|
123 |
} |
|
124 |
</style> |