zj
2024-06-03 561ca040085b6fd6766e471a70b4a3c682deadc2
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
import dayjs from "dayjs";
 
export default {
    data() {
        return {
            list: [], // 列表
            loading: false,
            finished: false,
            isLoading: false,
            form: { // 传递后端的参数
                page_no: 1, // 分页
                // start: dayjs().subtract(7, 'day').format('YYYY-MM-DD'), // 起始时间
                // end: dayjs().format('YYYY-MM-DD') // 终点时间
            }
        }
    },
    methods: {
        handleData(data) { // 往列表里拼接数据
            console.log('列表', data)
            this.isLoading = false;
            this.list = this.list.concat(data)
            this.loading = false
            if (data.length < 20) { // 小于十条 说明就是最后一组数据
                this.finished = true
                console.log('没有更多数据了')
            }
            this.form.page_no++ // 翻页
        },
        onRefresh() { // 下拉刷新
            console.log('refresh')
            this.form.page_no = 1
            this.list = []
            this.get()
        },
        onLoad() {
            console.log('onLoad')
            this.get()
        },
    }
}