diff --git a/.changeset/famous-dolls-tap.md b/.changeset/famous-dolls-tap.md
new file mode 100644
index 0000000000..980a17580b
--- /dev/null
+++ b/.changeset/famous-dolls-tap.md
@@ -0,0 +1,5 @@
+---
+'@td-design/lego': patch
+---
+
+lego中table组件的优化
diff --git a/packages/lego/example/TableDemo/demo1.tsx b/packages/lego/example/TableDemo/demo1.tsx
index 3f713a1604..f7cd1e8ef2 100644
--- a/packages/lego/example/TableDemo/demo1.tsx
+++ b/packages/lego/example/TableDemo/demo1.tsx
@@ -30,6 +30,34 @@ const data = [
model: '200',
money: '200元',
},
+ {
+ id: 5,
+ brand: '维特根5',
+ name: '沥青摊铺机',
+ model: '200',
+ money: '12988元',
+ },
+ {
+ id: 6,
+ brand: '徐工6',
+ name: '履带式挖掘机',
+ model: 'XE80CA',
+ money: '862.2元',
+ },
+ {
+ id: 7,
+ brand: '维特根7',
+ name: '沥青摊铺机',
+ model: '200',
+ money: '200元',
+ },
+ {
+ id: 8,
+ brand: '维特根8',
+ name: '沥青摊铺机',
+ model: '200',
+ money: '200元',
+ },
];
const columns = [
@@ -60,8 +88,8 @@ export default () => {
);
diff --git a/packages/lego/src/table/index.md b/packages/lego/src/table/index.md
index 2ca8c8c2e8..a876175dcb 100644
--- a/packages/lego/src/table/index.md
+++ b/packages/lego/src/table/index.md
@@ -15,11 +15,11 @@ group:
| ------------ | ------- | ---------------------- | ---------------------------------------------- | ------ |
| columns | `true` | 列数据 | `Column[]` | |
| data | `true` | 数据源 | `T[]` | |
+| height | `true` | 除了表头的表格内容高度 | `number` | |
+| countPreview | `true` | 每屏显示几条数据 | `number` | |
| speed | `false` | 速度(ms) | `number` | |
| autoplay | `false` | 自动轮播 | `boolean` | |
| inModal | `false` | 是否在弹窗中 | `boolean` | |
-| lineHeight | `false` | 自定义行高 | `number` | |
-| height | `false` | 除了表头的表格内容高度 | `number` | |
| colors | `false` | 自定义颜色 | `[string, string] \| [string, string, string]` | |
| headerClass | `false` | 表头的类 | `string` | |
| contentClass | `false` | 内容的类 | `string` | |
diff --git a/packages/lego/src/table/index.tsx b/packages/lego/src/table/index.tsx
index 0325fa8094..9682aec3a6 100644
--- a/packages/lego/src/table/index.tsx
+++ b/packages/lego/src/table/index.tsx
@@ -1,4 +1,4 @@
-import React, { memo, PropsWithChildren, ReactElement, ReactNode } from 'react';
+import React, { memo, PropsWithChildren, ReactElement } from 'react';
import classnames from 'classnames';
import { isEmpty } from 'lodash-es';
@@ -67,7 +67,7 @@ function Table>({
return { width };
};
- const slidesPerViewParams = countPreview > data?.length ?? 0 ? countPreview : data.length;
+ const slidesPerViewParams = countPreview > data.length ? data.length : countPreview;
const lineHeight = height / slidesPerViewParams;
return (