antd-vue中 我使用了table-tree 当我想展开一个的时候 树形结构全部展开了 如何修复
您可以在 TableTree 组件中使用 defaultExpandAll 属性将其设置为 false,这样就可以避免树形结构全部展开的问题。然后,在需要展开的节点上添加 expanded 属性,将其设置为 true,即可实现只展开指定节点的功能。具体代码如下:
<TableTree :data="data" :columns="columns" :defaultExpandAll="false">
<template slot-scope="{ row }">
<span v-if="row.children" @click="row.expanded = !row.expanded">
{{ row.expanded ? '收起' : '展开' }}
</span>
</template>
</TableTree>
在上述代码中,我们在 TableTree 组件中设置了 defaultExpandAll 属性为 false,然后在 template 中使用 slot-scope 对 row 进行解构,检查该节点是否有子节点,如果有,则在点击时将 expanded 属性设置为相反的值,以达到展开或收起子节点的效果。
原文地址: https://www.cveoy.top/t/topic/br8h 著作权归作者所有。请勿转载和采集!