Commit 3ed2339a6d75abbd6ccf723b6eaa762f9921409e

Authored by 无木
1 parent 6edca1c1

fix(tree): support defaultExpandAll prop

defaultExpandLevel已去除-1的行为定义,由defaultExpandAll代替。
src/components/Tree/src/Tree.vue
... ... @@ -211,12 +211,11 @@
211 211 });
212 212  
213 213 onMounted(() => {
214   - if (props.defaultExpandLevel === '') return;
215 214 const level = parseInt(props.defaultExpandLevel);
216   - if (level === -1) {
217   - expandAll(true);
218   - } else if (level > 0) {
  215 + if (level > 0) {
219 216 state.expandedKeys = filterByLevel(level);
  217 + } else if (props.defaultExpandAll) {
  218 + expandAll(true);
220 219 }
221 220 });
222 221  
... ...
src/components/Tree/src/props.ts
... ... @@ -27,6 +27,7 @@ export const basicProps = {
27 27 type: [String, Number] as PropType<string | number>,
28 28 default: '',
29 29 },
  30 + defaultExpandAll: propTypes.bool.def(false),
30 31  
31 32 replaceFields: {
32 33 type: Object as PropType<ReplaceFields>,
... ...
src/views/demo/tree/index.vue
... ... @@ -13,7 +13,7 @@
13 13 title="可勾选,默认全部展开"
14 14 :checkable="true"
15 15 class="w-1/3 mx-4"
16   - defaultExpandLevel="-1"
  16 + defaultExpandAll
17 17 @check="handleCheck"
18 18 />
19 19  
... ...