問題:在一個列表中展示多個table,且存在展開行,當切換分也后,前面頁面的展開行沒法點擊進行展開操作
點擊table設置當前點中的tableIndex
clickTable(index): void { this.currentTable = index; } 點擊展開按鈕,調用table的toggleRowExpansion方法 this.$table![this.currentTable]!.toggleRowExpansion(row);
初始點擊沒問題,但是切換頁碼后再切換回第一頁,點擊展開不生效了。
解決方法:換成使用row-key配合expand-row-key解決了

this.$nextTick(() => { // this.$table![this.currentTable]!.toggleRowExpansion(row); const index = this.expands.indexOf(id); if (index >= 0) { this.expands.splice(index, 1); } else { this.expands.push(id); } });