新版的iview中已經支持了合并單元格了,我的版本比較老,為:"iview": "^3.5.2"。暫不支持。記錄一下別的大佬的方法。感覺思路比較活,正在這種思路需要在解決問題的過程中學習。
核心思路:通過render方法,加上設置樣式實現看似合并單元格。
代碼如下:
data數據
dataList = [{index: '1',indexName: 'a',rate: '35%',standard: '描述11111',list: [{ info: "規則1", score: "100" },{ info: "規則2", score: "80" },{ info: "規則3", score: "60" },{ info: "規則4", score: "40" },]},{index: '2',indexName: 'b)',rate: '30%',standard: '描述2222'',list: [{ info: "規則1", score: "100" },{ info: "規則2", score: "80" },{ info: "規則3", score: "60" },{ info: "規則4", score: "40" },] }, ]
列的數據,在此數據中通過render來控制
columns: any[] = [{title: '序號',key: 'index'},{title: '指標',key: 'indexName'},{title: '權重',key: 'rate'},{title: '評分標準',key: 'standard'},{title: '詳情',key: 'list',width: 250,render: (h, params) => { return h('div', {attrs: {class: 'subCol'},}, [h('ul', params.row.list.map(item => {return h('li', {}, item.info)}))])}},{title: '分值',key: 'list',width: 100,render: (h, params) => { return h('div', {attrs: {class: 'subCol'},}, [h('ul', params.row.list.map(item => {return h('li', {}, item.score)}))])}}, ]
組件代碼
<Table :columns="columns" :data="dataList" :loading="loading" border></Table>
css
.subCol>ul>li {margin: 0 -18px;list-style: none;text-Align: center;padding: 9px;border-bottom: 1px solid #ccc;overflow-x: hidden;
}.subCol>ul>li:last-child {border-bottom: none
}
實現效果

image.png
參考網站:
https://blog.csdn.net/weixin_34138139/article/details/88600460
? 著作權歸作者所有,轉載或內容合作請聯系作者

喜歡的朋友記得點贊、收藏、關注哦!!!