
* chore: wip vxe-table * feat: add table demo * chore: follow ci recommendations to adjust details * chore: add custom-cell demo * feat: add custom-cell table demo * feat: add table from demo
64 lines
1.2 KiB
Vue
64 lines
1.2 KiB
Vue
<script lang="ts" setup>
|
|
import type { VxeGridProps } from '#/adapter';
|
|
|
|
import { onMounted } from 'vue';
|
|
|
|
import { Page } from '@vben/common-ui';
|
|
|
|
import { useVbenVxeGrid } from '#/adapter';
|
|
|
|
interface RowType {
|
|
id: number;
|
|
name: string;
|
|
role: string;
|
|
sex: string;
|
|
}
|
|
|
|
const gridOptions: VxeGridProps<RowType> = {
|
|
columns: [
|
|
{ type: 'seq', width: 70 },
|
|
{ field: 'name', title: 'Name' },
|
|
{ field: 'role', title: 'Role' },
|
|
{ field: 'sex', title: 'Sex' },
|
|
],
|
|
data: [],
|
|
height: 'auto',
|
|
scrollY: {
|
|
enabled: true,
|
|
gt: 0,
|
|
},
|
|
showOverflow: true,
|
|
};
|
|
|
|
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions });
|
|
|
|
// 模拟行数据
|
|
const loadList = (size = 200) => {
|
|
try {
|
|
const dataList: RowType[] = [];
|
|
for (let i = 0; i < size; i++) {
|
|
dataList.push({
|
|
id: 10_000 + i,
|
|
name: `Test${i}`,
|
|
role: 'Developer',
|
|
sex: '男',
|
|
});
|
|
}
|
|
gridApi.setGridOptions({ data: dataList });
|
|
} catch (error) {
|
|
console.error('Failed to load data:', error);
|
|
// Implement user-friendly error handling
|
|
}
|
|
};
|
|
|
|
onMounted(() => {
|
|
loadList(1000);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<Page auto-content-height>
|
|
<Grid />
|
|
</Page>
|
|
</template>
|