Commit 3ed2339a6d75abbd6ccf723b6eaa762f9921409e
1 parent
6edca1c1
fix(tree): support defaultExpandAll prop
defaultExpandLevel已去除-1的行为定义,由defaultExpandAll代替。
Showing
3 changed files
with
5 additions
and
5 deletions
src/components/Tree/src/Tree.vue
@@ -211,12 +211,11 @@ | @@ -211,12 +211,11 @@ | ||
211 | }); | 211 | }); |
212 | 212 | ||
213 | onMounted(() => { | 213 | onMounted(() => { |
214 | - if (props.defaultExpandLevel === '') return; | ||
215 | const level = parseInt(props.defaultExpandLevel); | 214 | const level = parseInt(props.defaultExpandLevel); |
216 | - if (level === -1) { | ||
217 | - expandAll(true); | ||
218 | - } else if (level > 0) { | 215 | + if (level > 0) { |
219 | state.expandedKeys = filterByLevel(level); | 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,6 +27,7 @@ export const basicProps = { | ||
27 | type: [String, Number] as PropType<string | number>, | 27 | type: [String, Number] as PropType<string | number>, |
28 | default: '', | 28 | default: '', |
29 | }, | 29 | }, |
30 | + defaultExpandAll: propTypes.bool.def(false), | ||
30 | 31 | ||
31 | replaceFields: { | 32 | replaceFields: { |
32 | type: Object as PropType<ReplaceFields>, | 33 | type: Object as PropType<ReplaceFields>, |
src/views/demo/tree/index.vue