Skip to content

前端分页

前端进行分页的hooks

Usage

vue
<template
    <a-table :columns="data.tableHeader" :dataSource="getPaginationList" :pagination="getPageOption">
    </a-table>
</template>

<script lang='ts' setup>
import { computed, reactive, ref } from 'vue';
import { usePagination } from '@qm-front-npm/hooks/vue';
import { ColumnType } from 'ant-design-vue/lib/table';
interface IDataProps {
    tableHeader: ColumnType[];
    pageOption: IPageOption
}
const data: IDataProps = reactive({
    tableHeader: []
});
const tableList = ref([]);
const { getPaginationList, setCurrentPage, setPageSize} = usePagination(tableList, 10);

const getPageOption = computed(() => ({
    onChange: (page: number, size: number) => {
        setCurrentPage(page);
        setPageSize(size);
    }
}));

</script>
<style lang='scss' scoped>
</style>

API

const { getPaginationList, setCurrentPage, setPageSize} = usePagination(tableList, pagesize);

参数类型说明
getPaginationListarray处理过的list文件
setCurrentPage(page: number)=>void设置当前页
setPageSize(size: number)=>void设置当前页大小

MIT Licensed