element table多層嵌套顯示的實(shí)踐
有個(gè)需求是一個(gè)列表,里面包含多個(gè)單子,每個(gè)單子可以是唯一,也可以是多個(gè)合并之后的,而且每個(gè)單子下面顯示的是另外一個(gè)表格,來(lái)上圖
每行的操作還不一樣,然后通過官網(wǎng)的一些例子總結(jié)了一下合并代碼
<template> <div class="app-container"> <div> <el-table :data="tableData" style="width: 100%;margin-bottom: 20px;" :span-method="arraySpanMethod" row-key="id" border > <el-table-column type="expand"> <template slot-scope="props"> <el-table class="table-in-table" :show-header="false" :data="props.row.datas" style="width: 100%;" row-key="id" :span-method="arraySpanMethod" border > <el-table-column type="expand"> <template slot-scope="props"> <el-table class="table-in-table" :data="props.row.datas" style="width: 100%;" row-key="id" border > <el-table-column prop="date" label="下單日期" width="180"></el-table-column> <el-table-column prop="type" label="單據(jù)類型" width="180"></el-table-column> <el-table-column prop="status" label="狀態(tài)"></el-table-column> <el-table-column label="操作" width="120"> <template slot-scope="props"> <el-button type="text" size="small">移除</el-button> </template> </el-table-column> </el-table> </template> </el-table-column> <el-table-column prop="applyNo" label="申請(qǐng)單號(hào)" width="132.2"></el-table-column> <el-table-column prop="name" label="姓名" width="180"></el-table-column> <el-table-column prop="address" label="地址"></el-table-column> </el-table> </template> </el-table-column> <el-table-column prop="applyNo" label="申請(qǐng)單號(hào)" width="180"></el-table-column> <el-table-column prop="name" label="姓名" width="180"></el-table-column> <el-table-column prop="address" label="地址"></el-table-column> <el-table-column label="操作" width="120"> <template slot-scope="props"> <el-button type="text" size="small">移除</el-button> </template> </el-table-column> </el-table> </div> </div> </template> <script> export default { name: "name1", components: {}, data() { return { tableData: [ { id: 1, applyNo: "202004291234", name: "李四", address: "上海市普陀區(qū)金沙江路 1518 弄" }, { id: 2, applyNo: "202004291235", name: "張三", address: "上海市普陀區(qū)金沙江路 1517 弄" }, { id: 3, applyNo: "202004291236,202004291237", name: "王五", address: "上海市普陀區(qū)金沙江路 1519 弄", datas: [ { id: 31, applyNo: "202004291236", name: "王五", address: "上海市普陀區(qū)金沙江路 1519 弄", datas: [ { id: 31, date: "2016-05-01", type: "類型1", status: "已發(fā)貨" }, { id: 32, date: "2016-05-01", type: "類型2", status: "未發(fā)貨" } ] }, { id: 32, applyNo: "202004291237", name: "王五", address: "上海市普陀區(qū)金沙江路 1519 弄" } ] }, { id: 4, applyNo: "202004291238", name: "趙6六", address: "上海市普陀區(qū)金沙江路 1516 弄" } ] }; }, methods: { arraySpanMethod({ row, column, rowIndex, columnIndex }) { if (!row.datas) { if (columnIndex === 0) { return [0, 0]; } else if (columnIndex === 1) { return [1, 2]; } } } } }; </script> <style lang="scss" scoped> .app-container { ::v-deep { .el-table th { background: #ddeeff; } .el-table__expanded-cell { border-bottom: 0px; border-right: 0px; padding: 0px 0px 0px 47px; } } .table-in-table { border-top: 0px; } } </style>
注:需要注意一點(diǎn)的是,這里面的孩子節(jié)點(diǎn)不能用children,因?yàn)楣俜侥J(rèn)是children,所以會(huì)出現(xiàn)別的下拉組件
設(shè)置td寬度的時(shí)候,需要注意的是里面跟外層的差47.8
到此這篇關(guān)于element table多層嵌套顯示的實(shí)踐的文章就介紹到這了,更多相關(guān)element table多層嵌套內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Ant Design Vue如何生成動(dòng)態(tài)菜單a-menu
這篇文章主要介紹了Ant Design Vue如何生成動(dòng)態(tài)菜單a-menu問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01vue可視化大屏實(shí)現(xiàn)無(wú)線滾動(dòng)列表飛入效果
本文主要介紹了vue可視化大屏實(shí)現(xiàn)無(wú)線滾動(dòng)列表飛入效果,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04vue中LocalStorage與SessionStorage的區(qū)別與用法
本文主要介紹了LocalStorage和SessionStorage。LocalStorage和SessionStorage是兩種存儲(chǔ)方式,本文詳細(xì)的介紹一下區(qū)別以及用法,感興趣的可以了解一下2021-09-09Vue+ElementUI實(shí)現(xiàn)從后臺(tái)動(dòng)態(tài)填充下拉框的示例代碼
本文主要介紹了Vue+ElementUI實(shí)現(xiàn)從后臺(tái)動(dòng)態(tài)填充下拉框的示例代碼,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02vue中將el-switch值true、false改為number類型的1和0
這篇文章主要介紹了vue中將el-switch值true、false改為number類型的1和0問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10