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