Files
heroui-vue/apps/docs/demos/table-column-resizing.vue

91 lines
2.9 KiB
Vue

<script setup lang="ts">
import {
Chip,
Table,
TableBody,
TableCell,
TableColumn,
TableColumnResizer,
TableContent,
TableHeader,
TableRow,
TableResizableContainer,
TableScrollContainer,
} from "@heroui-vue/components";
</script>
<template>
<Table>
<TableResizableContainer>
<TableScrollContainer>
<TableContent aria-label="可调整列宽的表格" class="min-w-[700px]">
<TableHeader>
<TableColumn
id="name"
is-row-header
default-width="1fr"
:min-width="160"
>
姓名
<TableColumnResizer />
</TableColumn>
<TableColumn id="role" default-width="1fr" :min-width="220">
角色
<TableColumnResizer />
</TableColumn>
<TableColumn id="status" default-width="1fr" :min-width="100">
状态
<TableColumnResizer />
</TableColumn>
<TableColumn id="email" default-width="1fr" :min-width="200">
邮箱
</TableColumn>
</TableHeader>
<TableBody>
<TableRow row-key="1">
<TableCell>Kate Moore</TableCell>
<TableCell>首席执行官</TableCell>
<TableCell>
<Chip color="success" size="sm" variant="soft">Active</Chip>
</TableCell>
<TableCell>kate@acme.com</TableCell>
</TableRow>
<TableRow row-key="2">
<TableCell>John Smith</TableCell>
<TableCell>首席技术官</TableCell>
<TableCell>
<Chip color="success" size="sm" variant="soft">Active</Chip>
</TableCell>
<TableCell>john@acme.com</TableCell>
</TableRow>
<TableRow row-key="3">
<TableCell>Sara Johnson</TableCell>
<TableCell>首席营销官</TableCell>
<TableCell>
<Chip color="warning" size="sm" variant="soft">On Leave</Chip>
</TableCell>
<TableCell>sara@acme.com</TableCell>
</TableRow>
<TableRow row-key="4">
<TableCell>Michael Brown</TableCell>
<TableCell>首席财务官</TableCell>
<TableCell>
<Chip color="success" size="sm" variant="soft">Active</Chip>
</TableCell>
<TableCell>michael@acme.com</TableCell>
</TableRow>
<TableRow row-key="5">
<TableCell>Emily Davis</TableCell>
<TableCell>产品经理</TableCell>
<TableCell>
<Chip color="danger" size="sm" variant="soft">Inactive</Chip>
</TableCell>
<TableCell>emily@acme.com</TableCell>
</TableRow>
</TableBody>
</TableContent>
</TableScrollContainer>
</TableResizableContainer>
</Table>
</template>