<el-col :span="24" class="toolbar pageBar">
    <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="currentPage1"
    :page-sizes="[10, 20, 30, 40]"
    :page-size="pageSize"
    layout=" prev, pager, next, sizes, total"
    :total="total">
    </el-pagination>
</el-col>
<script>
    export default {
            return {
                currentPage1: 1,
                total: 0,
                page: 1,
                pageSize: 10,
                pageNum:1
            }
        },
        methods: {
            //获取图表列表
            getUser: function () {
                let para = {
                    pageNum: this.pageNum,
                    pageSize: this.pageSize,
                };
                this.loading = true;
                getList(para).then((res) => {
                    if(res.data.success){
                        this.total = res.data.data.total;
                        this.currentPage1 = res.data.pageNum;
                        this.users = res.dataList;
                        this.loading = false;
                    }else{
                        this.loading = false;
                        this.$message({
                        message:  res.data.returnMsg,
                        type: 'error'
                        });
                    }
                })
            },
            //pageSize改变时
            handleSizeChange(val) {
                this.pageSize = val;
                this.getUser();
            },
            //pageNum改变时
            handleCurrentChange(val) {
                this.pageNum = val;
                this.getUser();
            },
        },
        mounted() {
            this.getUser();
        }
    };

</script>
  • size-change pageSize 改变时会触发 每页条数size current-change
  • currentPage 改变时会触发 当前页currentPage
Logo

前往低代码交流专区

更多推荐