背景: 官方說明文檔沒有具體代碼示例vue
1、官方文檔this
方法名: toggleRowExpansionurl
說明: 用於可展開表格,切換某一行的展開狀態,若是使用了第二個參數,則是設置這一行展開與否(expanded 爲 true 則展開)spa
參數: row, expanded.net
2、用法示例(vue.js)code
1 <template> 2 <el-table ref="topicTable" :row-key="getRowKeys" :data="tDt"> 3 <el-table-column type="expand">expand area</el-table-column> 4 <el-table-column label="column1"> 5 <template slot-scope="scope"> 6 <el-button @click="handleConnectionSearch(scope.row)"> 7 </el-button> 8 </template> 9 </el-table-column> 10 </el-table> 11 </template> 12 13 <script> 14 export default { 15 data() { 16 return { 17 tDt:[{id:1}, {id:2}] 18 } 19 }, 20 methods: { 21 handleConnectionSearch(row) { 22 this.$refs.topicTable.toggleRowExpansion(row, true) // 點擊button展開 23 }, 24 getRowKeys(row) { 25 return row.id 26 } 27 } 28 } 29 </script>