# 下拉刷新功能

page.json配置

"style": {
				"enablePullDownRefresh":true,
				"navigationBarTitleText": "小纸条",
				"app-plus": {
					...
				}
			}
1
2
3
4
5
6
7

paper.vue

<script>
	// 小纸条列表组件
	import paperList from '../../components/paper/paper-list.vue'
	export default {
		components: {
			paperList
		},
		data() {
			return {
				list: [
                  ......
				]
			}
		},
		// 监听下拉刷新
		onPullDownRefresh() {
			this.getData()
		},
		methods: {
			// 获取数据
			getData() {
				// 服务器获取数据
				let arr = [
					{
							userpic: '../../static/demo/userpic/10.jpg',
							username: '何疼',
							time: '10:10',
							data: '哈哈哈哈哈哈哈哈哈, 我来也',
							noreadnum: 19
						},
						{
							userpic: '../../static/demo/userpic/13.jpg',
							username: '马鑫',
							time: '10:10',
							data: '哈哈哈哈哈哈哈哈哈, 我来也',
							noreadnum: 9
						},
				]
				// 赋值
				this.list = arr
				// 关闭下拉刷新
				uni.stopPullDownRefresh()
			}
		}
	}
</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
上次更新: 2021/2/22 上午10:53:04