balmjs / balm-ui

:diamonds: A modular and customizable UI library based on Material Design and Vue
https://material.balmjs.com
MIT License
508 stars 30 forks source link

在UiTree组件中,使用 `defaultExpandedKeys` 不能展开全部树节点 #153

Closed guxuerui closed 1 year ago

guxuerui commented 1 year ago

Development Relevant Information:

Description:

在UiTree组件中,使用 defaultExpandedKeys 属性传递树节点的value值,但仍然只能默认展开顶级父节点

Steps To Reproduce:

  1. 使用组件
       <ui-tree
        v-model="selectedValue"
        :data="treeData"
        :data-format="dataFormat"
        :max-level="7"
        auto-expand-parent
        :default-expanded-keys="defaultKeys"
        class="itemColor"
        @selected="handleTreeSelect"
      />
  2. 传值
    
    const treeData = ref([
      {
        name: 'node1',
        code: 'org1',
        children: [
          {
            name: 'node1-1',
            code: 'org1-1',
            children: [
                {
                    name: 'ode2',
                    code: 'org2',
                    children: [
                      {
                        name: 'node2-1',
                        code: 'org2-1',
                      },
                    ],
                  },
            ]
          },
        ],
      },
    ])

const selectedValue = ref('')

const defaultKeys = ref(['org1', 'org1-1', 'org2', 'org2-1'])

const dataFormat = ref( { label: 'name', value: 'code' }, )



**这样写并不能展开所有节点,请问是我的`defaultExpandedKeys`传的值不对么?**
guxuerui commented 1 year ago

Thanks to the @elf-mouse , the problem has been solved!