element-ui table 实现表格展开行每次只能展开一行

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

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

1、table 部分

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

2、column 部分 :参见官方示例


      
 

3、data 部分

 data:{
       expands: [],
    },

4、method 部分

【注】设置展开区域的具体内容,就是在  expandSelect  这个方法内设置

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 = []
     }
},

 

你可能感兴趣的:(javascript,前端)