Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/tdesign-uniapp/.changelog/pr-4500.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
pr_number: 4500
contributor: betavs
---

- fix(Table): 修复列配置中的类名选项无效的问题 @betavs ([#4500](https://github.com/Tencent/tdesign-miniprogram/pull/4500))
15 changes: 15 additions & 0 deletions packages/uniapp-components/table/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,27 @@ export default {
return styles.join('; ');
},

getCustomClassName(className = '') {
const calcClassName = (name) => {
if (typeof name === 'function') {
return name() || '';
}
return name;
};

if (Array.isArray(className)) {
return className.map(calcClassName);
}
return [calcClassName(className)];
},

getThClassName(col, colIndex) {
const classes = [];
if (col.colKey) classes.push(`${name}__th-${col.colKey}`);
if (col.align && col.align !== 'left') classes.push(`${prefix}-align-${col.align}`);
if (col.fixed === 'left') classes.push(`${name}__cell--fixed-left`);
if (col.fixed === 'right') classes.push(`${name}__cell--fixed-right`);
if (col.className) classes.push(...this.getCustomClassName(col.className));
if (colIndex === this.lastFixedLeftIndex) classes.push(`${name}__cell--fixed-left-last`);
if (colIndex === this.firstFixedRightIndex) classes.push(`${name}__cell--fixed-right-first`);
return classes.join(' ');
Expand Down