nvue
# nvue大概模板
<template>
<view class="body">
<!-- 头部 -->
<view class="header" :style="{paddingTop:iStatusBarTop + 'px'}">
<view class="header-box">
<image class="box-img" mode="aspectFill" src="@/static/arrow-left.png"></image>
<text class="box-text">标题</text>
<image class="box-img" mode="aspectFill" src="@/static/more-dark.png"></image>
</view>
</view>
<!-- 内容 -->
<view class="content">
<!-- 添加list才能滚动 -->
<list ref="list" loadmoreoffset="10" @loadmore="loadMore">
<!-- 注意事项: 不能使用 index 作为 key 的唯一标识 -->
<refresh
:display="refreshing ? 'show' : 'hide'"
@refresh="onrefresh"
@pullingdown="onpullingdown"
>
<view class="loading-more">
<text>{{refreshText}}</text>
</view>
<loading-indicator></loading-indicator>
</refresh>
<!-- <cell>
<p v-for="item in 50">{{item}}</p>
</cell> -->
<cell>
<p v-for="item in 10">啊</p>
</cell>
<header>
吸顶吸顶吸顶
</header>
<cell v-for="(item, index) in listData" :key="index">
<text>{{item}}</text>
</cell>
</list>
</view>
<!-- 底部 -->
<view class="footer" :style="{paddingBottom:iStatusBarBottom + 'px'}">
<view class="footer-box">
<text class="box-text">按钮</text>
</view>
</view>
</view>
</template>
<script>
export default {
data () {
return {
iStatusBarTop : 0,
iStatusBarBottom : 0,
refreshing : false,
refreshText : '',
listData : [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],
tabTitle : ['王者','荣耀'],
}
},
onLoad () {
this.iStatusBarTop = uni.getSystemInfoSync().statusBarHeight;
this.iStatusBarBottom = uni.getSystemInfoSync().safeAreaInsets.bottom;
},
// onReachBottom () {
// console.log('触底了');
// },
methods : {
// lower1 () {
// console.log('触底了触底了触底了');
// },
loadMore () {
// this.$refs["list"].resetLoadmore();
this.listData.push(...[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]);
uni.showToast({
icon : 'none',
title : '触底了触底了触底了'
})
console.log('触底了触底了触底了');
},
onrefresh () {
// this.$refs["list"].resetLoadmore();
this.listData = [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];
uni.showToast({
icon : 'none',
title : '下拉刷新了'
})
console.log('下拉刷新了');
console.log('onrefresh');
this.refreshing = true;
setTimeout(() => {
this.refreshing = false;
}, 1000);
},
onpullingdown (e) {
if (this.refreshing) {
console.log('111111111111');
return;
}
if (Math.abs(e.pullingDistance) > Math.abs(e.viewHeight)) {
this.refreshText = '释放立即刷新';
} else {
this.refreshText = '下拉可以刷新';
}
// uni.showToast({
// icon : 'none',
// title : '手触摸了'
// })
// console.log('onpullingdown');
}
},
// loadmore () {
// console.log('触底了触底了触底了');
// }
}
</script>
<style lang="scss" scoped>
.body {
flex:1;
.header {
background-color: #58a3ff;
.header-box {
flex-direction: row;
align-items: center;
justify-content: space-between;
padding:0 40rpx;
height: 44px;
background-color: #58a3ff;
.box-img {
height:48rpx;
width:48rpx;
}
.box-text {
font-size: 32rpx;
font-weight: bold;
}
}
}
.content {
flex:1;
background-color: #f0e8dd;
}
.footer {
padding:10rpx 40rpx;
box-shadow: 0 -6rpx 20rpx rgba(0, 0, 0, 0.05);
.footer-box {
padding:24rpx 0;
background: #FF6E01;
border-radius: 44rpx;
.box-text {
text-align: center;
font-size: 28rpx;
color: #FFFFFF;
font-weight: bold;
}
}
}
}
.loading-more {
align-items: center;
justify-content: center;
padding-top: 14px;
padding-bottom: 14px;
text-align: center;
flex-direction: row;
width:750rpx;
}
</style>
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
上次更新: 5/13/2023, 5:48:10 PM