<a-table
:columns="columns"
:data-source="state.dataSource"
:pagination="state.pagination"
class="components-table-demo-nested"
@expand="expand"
:row-key="(record) => record.id"
:expandedRowKeys="expandedRowKeys"
>
<template #expandedRowRender="{ record }">
<a-table
:columns="columns"
:data-source="data.get(record.groupCode)"
:pagination="false"
:scroll="{ y: 240 }"
>
</a-table>
</template>
</a-table>
逻辑代码
const expand = async (expanded, record) => {
if (expanded) {
let code = record.groupCode;
let res = await getSecondAlarmRecord(code);
data.set(code, res.data);
expandedRowKeys.value.push(record.id);
} else {
let index = expandedRowKeys.value.indexOf(record.id);
expandedRowKeys.value.splice(index, 1);
}
};