Skip to content

table组件如何使用columns来自定义表头 #8154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
appleqzw opened this issue May 6, 2025 · 2 comments
Closed
1 task

table组件如何使用columns来自定义表头 #8154

appleqzw opened this issue May 6, 2025 · 2 comments

Comments

@appleqzw
Copy link

appleqzw commented May 6, 2025

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.2.6

Environment

win10 pnpm10

Reproduction link

https://next.antdv.com/components/table-cn/#column

Steps to reproduce

是否可以使用columns来自定义表头?封装的通用表格组件,不想在template中单独写额外逻辑来自定义表头

What is expected?

可以使用columns来自定义表头,最简单的比如表头加icon之类的

What is actually happening?

没找到文档中如何使用columns来自定义表头

@selicens
Copy link
Member

selicens commented May 7, 2025

use title

columns: [
  {
    title: '姓名',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '年龄',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: h('div', [
      h(例如你说的icon),
      h('span', '性别')
    ]),
    key: 'sex'
  }
]

@appleqzw
Copy link
Author

appleqzw commented May 7, 2025

use title

columns: [
{
title: '姓名',
dataIndex: 'name',
key: 'name',
},
{
title: '年龄',
dataIndex: 'age',
key: 'age',
},
{
title: h('div', [
h(例如你说的icon),
h('span', '性别')
]),
key: 'sex'
}
]

可行,谢谢
不过文档里只写了title的类型是String,没有写可以用vnode 😢

Image

@appleqzw appleqzw closed this as completed May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants