# 6.3 上拉加载
# 实例
# 基础用法
<template>
<div class="dof-demo">
<dof-minibar
title="上拉加载"
background-color="#ffffff"
:isImage="true"
:left-button="leftButton"
@dofMinibarLeftButtonClicked="back"
@dofMinibarRightButtonClicked="minibarRightButtonClick"
></dof-minibar>
<scroller class="scroller">
<div class="cell" v-for="num in lists" :key="num">
<div class="panel">
<text class="text">{{ num }}</text>
</div>
</div>
<loading class="loading" @loading="onloading" :display="loadinging ? 'show' : 'hide'" v-if="nextPageFlag">
<!-- <text class="indicator-text">Loading ...</text> -->
<midea-apng-view :loop="true" :auto="true" :src="loadingIcon" class="indicator"></midea-apng-view>
</loading>
<text class="tips" v-if="!nextPageFlag">- 没有更多内容了 - </text>
</scroller>
</div>
</template>
<style scoped>
.dof-demo {
background-color: #f9f9f9;
}
.loading {
width: 750;
display: -ms-flex;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-align-items: center;
-webkit-box-align: center;
align-items: center;
padding-bottom: 40px;
}
.indicator-text {
color: #888888;
font-size: 42px;
text-align: center;
}
.indicator {
margin-top: 16px;
height: 40px;
width: 40px;
color: blue;
}
.panel {
width: 686px;
height: 344px;
margin-left: 32px;
margin-top: 35px;
margin-bottom: 35px;
flex-direction: column;
justify-content: center;
border-radius: 32px;
background-color: #ffffff;
}
.text {
font-size: 50px;
text-align: center;
color: #41b883;
}
.tips {
color: #8a8a8f;
font-size: 24px;
margin-top: 80px;
padding-bottom: 80px;
text-align: center;
}
</style>
<script>
import { DofMinibar } from 'dolphin-weex-ui'
const modal = weex.requireModule('modal')
export default {
components: { DofMinibar },
data: () => ({
loadinging: false,
maxPage: 3,
currPage: 1,
pageSize: 5,
lists: [0, 1, 2, 3, 4],
loadingIcon: 'http://dolphin-weex-dev.msmartlife.cn/cdn/images/common/loading_gray.png',
nextPageFlag: true
}),
created() {},
computed: {},
mounted() {},
methods: {
onloading() {
modal.toast({ message: 'Loading' })
this.loadinging = true
setTimeout(() => {
this.initData()
this.loadinging = false
}, 2000)
},
initData() {
if (this.currPage >= this.maxPage) {
this.nextPageFlag = false
return
}
for (let i = this.currPage * this.pageSize; i < (this.currPage + 1) * this.pageSize; i++) {
this.lists.push(i)
}
this.currPage += 1
}
}
}
</script>
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117