Skip to content

Commit 68b5359

Browse files
committed
补充表格动态高度示例
1 parent fe549c8 commit 68b5359

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
:::anchor 动态高度
2+
3+
:::demo 你可以使用 [calc css 函数](<https://developer.mozilla.org/en-US/docs/Web/CSS/calc()>) 实现表格动态高度。如 `max-height="calc(100vh - 10px)"` 或者 `max-height="calc(100% - 10px)"`
4+
5+
```html
6+
<template>
7+
<ve-table
8+
max-height="calc(100vh - 350px)"
9+
fixed-header
10+
:columns="columns"
11+
:table-data="tableData"
12+
/>
13+
</template>
14+
15+
<script>
16+
export default {
17+
data() {
18+
return {
19+
columns: [
20+
{ field: "name", key: "a", title: "Name", align: "center" },
21+
{ field: "date", key: "b", title: "Date", align: "left" },
22+
{ field: "hobby", key: "c", title: "Hobby", align: "center" },
23+
{ field: "address", key: "d", title: "Address", align: "left" },
24+
],
25+
tableData: [],
26+
};
27+
},
28+
methods: {
29+
initTableData() {
30+
let data = [];
31+
for (let i = 0; i < 20; i++) {
32+
data.push({
33+
name: i,
34+
date: i,
35+
hobby: i,
36+
address: i,
37+
});
38+
}
39+
this.tableData = data;
40+
},
41+
},
42+
created() {
43+
this.initTableData();
44+
},
45+
};
46+
</script>
47+
```
48+
49+
:::

examples/src/docs/zh/ve-table/header-fixed/main.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
<Explain />
55
<Base />
66
<AutoHeight />
7+
<DynamicHeight />
78
<HeaderFixedDisabled />
89
</div>
910
</template>
1011
<script>
1112
import Explain from "./explain.md";
1213
import Base from "./base.md";
1314
import AutoHeight from "./auto-height.md";
15+
import DynamicHeight from "./dynamic-height.md";
1416
import HeaderFixedDisabled from "./header-fixed-disabled.md";
1517
1618
export default {
@@ -19,6 +21,7 @@ export default {
1921
Explain,
2022
Base,
2123
AutoHeight,
24+
DynamicHeight,
2225
HeaderFixedDisabled
2326
}
2427
};

0 commit comments

Comments
 (0)