因为defaultExpandAllRows只会在第一次渲染时起作用,此时数据还未加载,因此不生效
所以只需在数据加载后让其生效即可,加一个条件v-if='data.length'。
<a-table
v-if="data.length"
:loading="loading"
:dataSource="data"
:columns="columns"
rowKey="id"
:defaultExpandAllRows="true"
:scroll="{ y: tableHeight }"
>
</a-table>


文章描述了在数据未加载时defaultExpandAllRows属性不会生效的问题,提出解决方案是在数据加载后通过v-if条件判断使A-Table组件渲染,确保defaultExpandAllRows在数据存在时正确设置,从而实现全部行展开功能。
581

被折叠的 条评论
为什么被折叠?



