elementui 表头合并,两列共用一个表头,header-cell-style设置表头样式
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
下图是要实现的效果
HTML
通过header-cell-style给table表头设置样式
<el-table :data="tableData" style="width: 100%" :header-cell-style="rowClass">
<el-table-column label="建设任务内容" min-width="200">
<el-table-column label="" prop="projectName" show-overflow-tooltip min-width="100"> </el-table-column>
<el-table-column label="" prop="projectContent" show-overflow-tooltip min-width="150"></el-table-column>
</el-table-column>
<el-table-column label="计划投资">
<el-table-column prop="investPlan" :label="planTotal" show-overflow-tooltip min-width="120"> </el-table-column>
</el-table-column>
<el-table-column label="实际投资">
<el-table-column prop="investActually" :label="actuallyTotal" show-overflow-tooltip min-width="120"></el-table-column>
</el-table-column>
<el-table-column label="投资完成率">
<el-table-column prop="rateOfInvest" :label="rateOfInvest" show-overflow-tooltip min-width="120"> </el-table-column>
</el-table-column>
</el-table>
data
data() {
return {
planTotal:"100", //计划投资
actuallyTotal:"100", //实际投资
rateOfInvest:"100%", //投资完成率
tableData: [{
projectName: '主导产业提升工程',
projectContent: '主导产业提升工程的内容描述巴拉巴拉巴拉',
investPlan: '920',
investActually: '1565.41',
rateOfInvest: '170.15',
}]
}
},
methods
methods: {
rowClass({ row, column,rowIndex,columnIndex}) {
if(rowIndex===0 && columnIndex===0) {
this.$nextTick(()=> {
if(document.getElementsByClassName(column.id).length!==0) {
document.getElementsByClassName(column.id)[0].setAttribute('rowSpan',2);
return false
}
})
}
if(rowIndex===1 && (columnIndex===0 || columnIndex===1)) {
return {display:'none'}
}
}
},
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)