element-ui table 實現表格展開行每次只能展開一行


 

1、table 部分

:row-key='getRowKeys'
:expand-row-keys="expands"
@expand-change="expandSelect"

2、column 部分 :參見官方示例

<el-table-column type="expand" >
      <template slot-scope="props">
       XXXX
      </template>
 </el-table-column>

3、data部分

 data:{
       expands: [],
 },

4、methods部分

getRowKeys: function (row) {
return row.id
},
expandSelect: function (row, expandedRows) {
var that = this
if (expandedRows.length) {
that.expands = []
if (row) {
that.expands.push(row.id)
}
} else {
that.expands = []
}
}

 

 

參考:

https://www.cnblogs.com/qianjin888/p/10246108.html

https://blog.csdn.net/katy_1/article/details/85113191


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM