fix(table): align constrained widths and guard invalid fr factors
This commit is contained in:
Vendored
+35
-2
@@ -24,6 +24,9 @@ const widths = [620, 900, 1400];
|
||||
const hostWidth = ref(900);
|
||||
const rtl = ref(false);
|
||||
const dark = ref(false);
|
||||
const layoutCase = ref("baseline");
|
||||
const showRows = ref(true);
|
||||
const extraColumn = ref(false);
|
||||
watch(
|
||||
dark,
|
||||
(value) => {
|
||||
@@ -41,6 +44,14 @@ const rows = [
|
||||
<template>
|
||||
<main style="padding: 24px; display: grid; gap: 16px">
|
||||
<div style="display: flex; gap: 16px">
|
||||
<label>
|
||||
边界场景
|
||||
<select v-model="layoutCase">
|
||||
<option value="baseline">常规列宽</option>
|
||||
<option value="fixed-max">固定列超出上限</option>
|
||||
<option value="invalid-fr">无效 fr 回退</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
容器宽度
|
||||
<select v-model.number="hostWidth">
|
||||
@@ -57,6 +68,14 @@ const rows = [
|
||||
<input v-model="dark" type="checkbox" />
|
||||
深色主题
|
||||
</label>
|
||||
<label>
|
||||
<input v-model="showRows" type="checkbox" />
|
||||
显示数据
|
||||
</label>
|
||||
<label>
|
||||
<input v-model="extraColumn" type="checkbox" />
|
||||
增加列
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
id="table-host"
|
||||
@@ -72,6 +91,7 @@ const rows = [
|
||||
id="name"
|
||||
allows-sorting
|
||||
default-width="1fr"
|
||||
:width="layoutCase === 'invalid-fr' ? 'oopsfr' : undefined"
|
||||
:min-width="120"
|
||||
>
|
||||
<TableSortableColumnHeader>姓名</TableSortableColumnHeader>
|
||||
@@ -81,18 +101,31 @@ const rows = [
|
||||
角色
|
||||
<TableColumnResizer />
|
||||
</TableColumn>
|
||||
<TableColumn id="status" :width="180">状态</TableColumn>
|
||||
<TableColumn
|
||||
id="status"
|
||||
:width="180"
|
||||
:max-width="layoutCase === 'fixed-max' ? 100 : undefined"
|
||||
>
|
||||
状态
|
||||
</TableColumn>
|
||||
<TableColumn id="email" width="20%" :max-width="240">
|
||||
邮箱
|
||||
</TableColumn>
|
||||
<TableColumn v-if="extraColumn" id="extra">附加列</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow v-for="row in rows" :key="row.id" :row-key="row.id">
|
||||
<TableRow
|
||||
v-for="row in showRows ? rows : []"
|
||||
:key="row.id"
|
||||
:row-key="row.id"
|
||||
>
|
||||
<TableCell>{{ row.name }}</TableCell>
|
||||
<TableCell>{{ row.role }}</TableCell>
|
||||
<TableCell>在职</TableCell>
|
||||
<TableCell>{{ row.email }}</TableCell>
|
||||
<TableCell v-if="extraColumn">附加内容</TableCell>
|
||||
</TableRow>
|
||||
<template #empty>未找到结果</template>
|
||||
</TableBody>
|
||||
</TableContent>
|
||||
</TableScrollContainer>
|
||||
|
||||
Reference in New Issue
Block a user