diff --git a/components/vc-table/src/BaseTable.jsx b/components/vc-table/src/BaseTable.jsx
index 016c04930..4ecfd5bbb 100644
--- a/components/vc-table/src/BaseTable.jsx
+++ b/components/vc-table/src/BaseTable.jsx
@@ -141,7 +141,7 @@ const BaseTable = {
render() {
const { sComponents: components, prefixCls, scroll, data } = this.table;
const { expander, tableClassName, hasHead, hasBody, fixed, isAnyColumnsFixed } = this.$props;
-
+ const columns = this.getColumns();
const tableStyle = {};
if (!fixed && scroll.x) {
@@ -153,6 +153,14 @@ const BaseTable = {
tableStyle.width =
typeof tableStyle.width === 'number' ? `${tableStyle.width}px` : tableStyle.width;
}
+ if (fixed) {
+ const width = columns.reduce((sum, { width: w }) => {
+ return sum + parseFloat(w, 10);
+ }, 0);
+ if (width > 0) {
+ tableStyle.width = width + 'px';
+ }
+ }
const Table = hasBody ? components.table : 'table';
const BodyWrapper = components.body.wrapper;
@@ -161,7 +169,7 @@ const BaseTable = {
if (hasBody) {
body =