How do I add custom attributes to the columns of Table in elementUI?

html Code

now only this information is added to the column by myself. I want to add an id attribute to column, how to add it, or if there is any attribute that I can use to put some custom information

Apr.02,2021

you don't need to use a custom property, you can assign a value to it, and you can get this property in html


mm-hmm, got it. Setting column-key is indeed a method, but considering its uniqueness, it is not appropriate if your custom properties may be duplicated. On the contrary, if the custom attribute is id and unique, you might as well use it boldly.
if you must customize an attribute that does not affect other functions, you can use render-header to render the header, and add the attribute to column during render:

<el-table-column :render-header="renderHeader"></el-table-column>
...
renderHeader(h, { column, $index }) {
  column.test = 'test'
  console.log(column) // 
  return (
    <span></span>
  )
}
...
// :render`ElTable`
Menu