在使用BasicTree发现即使使用了defaultExpandAll的属性也不展开的问题,其实问题很简单,和defaultExpandAll没有一点关系,是数据获取的问题。咱们做个小例子。
本地数据
//组件
<BasicTree
:treeData="finalTreeData"
selectable
@select="handleSelect"
:selectedKeys="selectedKeys"
defaultExpandAll
/>
//script中定义数据
const finalTreeData = ref([] as any);
finalTreeData.value = [
{
key: '1',
title: '苹果',
children: [
{
key: '11',
title: '苹果1',
},
{
key: '12',
title: '苹果2',
},
{
key: '13',
title: '苹果3',
},
],
},
{
key: '2',
title: '梨子',
children: [
{
key: '21',
title: '梨子1',
},
{
k