借鉴:添加链接描述
使用 toggleRowExpansion
补充内容:
data() {
return {
tableData: list,
//⭐展开的内容表格数据
versionData: [],
currentPage: 1,
pagesize: 10,
loading: true,
getRowKeys(row) { return row.id },
expands: [],
//⭐ 判断是否打开
isOpen: false,
//保存上一次点击的行
lastRow:{}
}
},
methods: {
//⭐
cellClick(row, column, event) {
var that = this
this.$refs.multipleTable.toggleRowExpansion(that.lastRow, false)
if (row == that.lastRow) {
// that.isOpen = !that.isOpen
if (that.isOpen == true) {
//本来已经打开
//改成关闭
that.isOpen = false
//
that.$refs.multipleTable.toggleRowExpansion(that.lastRow, false)
} else {
//本来是关闭
//改成打开
that.isOpen = true
that.$refs.multipleTable.toggleRowExpansion(row)
//获取展开内容的表格数据
var file_id = row.id
getVersion(file_id).then(list => {
that.versionData = list
})
}
} else {
that.isOpen = true
if (event.cellIndex != 0) {
this.$refs.multipleTable.toggleRowExpansion(row)
this.lastRow = row
//获取展开内容的表格数据
var file_id = row.id
getVersion(file_id).then(list => {
that.versionData = list
})
}
}
},