# 下拉刷新实现
pages.json
"style": {
"enablePullDownRefresh":true, // 开启下拉刷新
"app-plus": {
....
}
}
1
2
3
4
5
6
2
3
4
5
6
topic-detail.vue
// 监听下拉刷新
onPullDownRefresh() {
this.getData()
},
methods: {
// 下拉刷新
getData() {
// 关闭下拉刷新
setTimeout(() => {
// 获取数据
let arr = [
// 图文
{
userpic: '../../static/demo/userpic/17.jpg',
username: '哈哈22222222222222',
sex: 1, // 0 男 1 女
age: 24,
isguanzhu: true,
title: '我是标题11',
titlepic: '../../static/demo/datapic/13.jpg',
video: false,
share: false,
path: '湖南 长沙',
sharenum: 20,
commentnum: 30,
goodnum: 20
},
// 文字
{
userpic: '../../static/demo/userpic/17.jpg',
username: '哈哈1457',
sex: 0, // 0 男 1 女
age: 25,
isguanzhu: false,
title: '我是标题',
titlepic: '',
video: false,
share: false,
path: '湖南 长沙',
sharenum: 20,
commentnum: 30,
goodnum: 20
},
// 视频
{
userpic: '../../static/demo/userpic/17.jpg',
username: '哈哈',
sex: 0, // 0 男 1 女
age: 25,
isguanzhu: false,
title: '我是标题',
titlepic: '../../static/demo/datapic/13.jpg',
video: {
loopnum: "20w",
long: "2:47"
},
share: false,
path: '湖南 长沙',
sharenum: 20,
commentnum: 30,
goodnum: 20
}
]
// 赋值
this.tabList[this.tabIndex].list = arr
uni.stopPullDownRefresh()
}, 2000)
}
}
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
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
← 上啦加载实现 小纸条page.json配置 →