ElementUI的Table表格,官方網站上提供了很多樣式,但是在日常開發中還會碰到各種情況,顯然官方提供的是不能滿足需求的。那么,我們就根據自己的需求對table進行改造。
先丟出關於Table的官方文檔的傳送門,請戳這里→ http://element-cn.eleme.io/#/zh-CN/component/table
官方對Table相關的Attributes介紹的不是很詳細,對於不太熟悉人,很難搞明白,實際操作起來很難受。
下面就關於Table-column中render-header的運用,稍作說明,具體請移步此項目文件中查看(文章最下面有傳送門)。
參數 | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
render-header | 列標題 Label 區域渲染使用的 Function | Function(h, { column, $index }) | — | — |
一、自定義表頭樣式
renderHeaderOne (h, { column, $index }) {
return h('span', [
h('span', column.label),
h('span', {
class: 'errorIcon',
on: {
click: () => {
console.log(`${column.label} ${$index}`)
}
}
})
])
}
二、自定義表頭樣式和整列的拖動
renderHeader (h, { column, $index }) {
// 這里可以根據$index的值來對自身需求進行修改,
return h('span', {
'class': ['thead-cell'],
on: {
mousedown: ($event) => { this.handleMouseDown($event, column) },
mouseup: ($event) => { this.handleMouseUp($event, column) },
mousemove: ($event) => { this.handleMouseMove($event, column) }
}
}, [
h('span', [
h('span',
{
class: $index === 0 ? 'el-icon-star-off' : $index === 1 ? 'el-icon-time' : $index === 2 ? 'el-icon-location' : '',
style: {
// marginLeft: ''
},
on: {
}
}),
h('span', column.label)
]),
h('span', {
'class': ['virtual']
})
])
}
DEMO傳送門,請戳這里→ https://github.com/Darkerxi/ElementUI-Table-column_render-header