<el-table :data="tableData" @expand-change="expandChange" ref="refTable"> <el-table-column type="expand"> </el-table-column> <el-table> expandChange(row,expandedRows){ var that = this if (expandedRows.length>1) { that.expands = [] if (row) { that.expands.push(row); } this.$refs.refTable.toggleRowExpansion(expandedRows[0]); } else { that.expands = []; } },
主要就是使用el-table的@expand-change方法,並添加ref
注:記得在data中定義變量expands