From 749d74e21f64bd73764cc158f9d35aea372a436f Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Fri, 20 Mar 2020 18:38:47 +0800 Subject: [PATCH] fix: table error when use template #1914 --- components/table/Table.jsx | 6 ++++-- components/vc-table/index.js | 7 +++++++ components/vc-table/src/TableHeaderRow.jsx | 6 ++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/components/table/Table.jsx b/components/table/Table.jsx index 4fa86790d..5b13508f1 100755 --- a/components/table/Table.jsx +++ b/components/table/Table.jsx @@ -490,13 +490,15 @@ export default { return getPopupContainer; } // Use undefined to let rc component use default logic. - return scroll && table ? () => table.tableNode : undefined; + return scroll && table ? () => table.getTableNode() : undefined; }, scrollToFirstRow() { const { scroll } = this.$props; if (scroll && scroll.scrollToFirstRowOnChange !== false) { scrollTo(0, { - getContainer: () => this.$refs.vcTable.bodyTable, + getContainer: () => { + return this.$refs.vcTable.getBodyTable(); + }, }); } }, diff --git a/components/vc-table/index.js b/components/vc-table/index.js index 614c47784..57a299952 100644 --- a/components/vc-table/index.js +++ b/components/vc-table/index.js @@ -20,6 +20,12 @@ const Table = { ColumnGroup, props: T.props, methods: { + getTableNode() { + return this.$refs.table.tableNode; + }, + getBodyTable() { + return this.$refs.table.ref_bodyTable; + }, normalize(elements = []) { const columns = []; elements.forEach(element => { @@ -63,6 +69,7 @@ const Table = { columns, }, on: getListeners(this), + ref: 'table', }; return ; }, diff --git a/components/vc-table/src/TableHeaderRow.jsx b/components/vc-table/src/TableHeaderRow.jsx index 107691b05..38c93f839 100644 --- a/components/vc-table/src/TableHeaderRow.jsx +++ b/components/vc-table/src/TableHeaderRow.jsx @@ -51,8 +51,10 @@ const TableHeaderRow = { } headerCellProps.class = classNames( - customProps.class || customProps.className, - column.class || column.className, + customProps.class, + customProps.className, + column.class, + column.className, { [`${prefixCls}-align-${column.align}`]: !!column.align, [`${prefixCls}-row-cell-ellipsis`]: !!column.ellipsis,