<el-table :span-method="arraySpanMethod">
</el-table>
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
},
<el-table :span-method="arraySpanMethod">
</el-table>
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
},
jsfiddle 的 demo 链接:https://jsfiddle.net/liangxh/...
watch: {
tableData: {
handler(nv) {
let tempMergeIndex = [];
// 处理arr,生成一个与行数相同的数组记录每一行设置的合并数
for(let i = 0; i < nv.length;i++) {
tempMergeIndex[i] = i < 2 ? 1 : i === 2 ? nv.length - 2 : 0;
}
this.tempIndex = tempMergeIndex;
},
deep: true,
immediate: true
}
},
methods: {
// 从 tempIndex 获取当前 row 需要合并的行数
handleSameMerge({row, column, rowIndex, columnIndex}) {
if (columnIndex === 0) {
return {
rowspan: this.tempIndex[rowIndex],
colspan: 1
}
}
}
}
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决