vue elementui type=expand 设置只可以展开一行、设置点击行即可打开扩展内容

1、设置只可以展开一行

table里面事件添加

<el-table class="elTable" ref="machineTable"   :data="machineDataList" 
:row-key="(row) => { return row.id }"
@expand-change="handleExpandChange"
@row-click="handledetail11">

method:

                handleExpandChange(row,rows){
                    var that = this
                    if (rows.length>1) {
                        that.expands = []
                        if (row) {
                            that.expands.push(row);
                        }
                        this.$refs.machineTable.toggleRowExpansion(rows[0]);
                    } else {
                        that.expands = [];
                    }
                }

data:

expands:[]

 2、设置点击行即可打开扩展内容

handledetail11(row, column, event) {
                    this.$refs.machineTable.toggleRowExpansion(row)
                },

3、隐藏表格扩展隐藏图标

<el-table-column type="expand" width="1" >

 

 

 

 



 

posted @ 2022-12-09 16:58  凉面好好吃  阅读(2813)  评论(0编辑  收藏  举报