Commit 37f4b7a8795d2b4cda4cce746b62cc8dd40b4cb0
1 parent
d082f8cc
Tree add global setting, update transition component, #5592 , close #5596
Showing
3 changed files
with
61 additions
and
6 deletions
Show diff stats
src/components/base/collapse-transition.js
... | ... | @@ -67,9 +67,15 @@ const Transition = { |
67 | 67 | export default { |
68 | 68 | name: 'CollapseTransition', |
69 | 69 | functional: true, |
70 | - render(h, { children }) { | |
70 | + props: { | |
71 | + appear: Boolean | |
72 | + }, | |
73 | + render(h, { children, props }) { | |
71 | 74 | const data = { |
72 | - on: Transition | |
75 | + on: Transition, | |
76 | + props: { | |
77 | + appear: props.appear | |
78 | + } | |
73 | 79 | }; |
74 | 80 | |
75 | 81 | return h('transition', data, children); | ... | ... |
src/components/tree/node.vue
1 | 1 | <template> |
2 | - <collapse-transition> | |
2 | + <collapse-transition :appear="appear"> | |
3 | 3 | <ul :class="classes"> |
4 | 4 | <li> |
5 | 5 | <span :class="arrowClasses" @click="handleExpand"> |
6 | - <Icon v-if="showArrow" type="ios-arrow-forward"></Icon> | |
7 | - <Icon v-if="showLoading" type="ios-loading" class="ivu-load-loop"></Icon> | |
6 | + <Icon v-if="showArrow" :type="arrowType" :custom="customArrowType" :size="arrowSize" /> | |
7 | + <Icon v-if="showLoading" type="ios-loading" class="ivu-load-loop" /> | |
8 | 8 | </span> |
9 | 9 | <Checkbox |
10 | 10 | v-if="showCheckbox" |
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | <span v-else :class="titleClasses" @click="handleSelect">{{ data.title }}</span> |
18 | 18 | <Tree-node |
19 | 19 | v-if="data.expand" |
20 | + :appear="appearByClickArrow" | |
20 | 21 | v-for="(item, i) in children" |
21 | 22 | :key="i" |
22 | 23 | :data="item" |
... | ... | @@ -61,11 +62,16 @@ |
61 | 62 | showCheckbox: { |
62 | 63 | type: Boolean, |
63 | 64 | default: false |
65 | + }, | |
66 | + appear: { | |
67 | + type: Boolean, | |
68 | + default: false | |
64 | 69 | } |
65 | 70 | }, |
66 | 71 | data () { |
67 | 72 | return { |
68 | - prefixCls: prefixCls | |
73 | + prefixCls: prefixCls, | |
74 | + appearByClickArrow: false | |
69 | 75 | }; |
70 | 76 | }, |
71 | 77 | computed: { |
... | ... | @@ -127,6 +133,41 @@ |
127 | 133 | }, |
128 | 134 | children () { |
129 | 135 | return this.data[this.childrenKey]; |
136 | + }, | |
137 | + // 3.4.0, global setting customArrow 有值时,arrow 赋值空 | |
138 | + arrowType () { | |
139 | + let type = 'ios-arrow-forward'; | |
140 | + | |
141 | + if (this.$IVIEW) { | |
142 | + if (this.$IVIEW.tree.customArrow) { | |
143 | + type = ''; | |
144 | + } else if (this.$IVIEW.tree.arrow) { | |
145 | + type = this.$IVIEW.tree.arrow; | |
146 | + } | |
147 | + } | |
148 | + return type; | |
149 | + }, | |
150 | + // 3.4.0, global setting | |
151 | + customArrowType () { | |
152 | + let type = ''; | |
153 | + | |
154 | + if (this.$IVIEW) { | |
155 | + if (this.$IVIEW.tree.customArrow) { | |
156 | + type = this.$IVIEW.tree.customArrow; | |
157 | + } | |
158 | + } | |
159 | + return type; | |
160 | + }, | |
161 | + // 3.4.0, global setting | |
162 | + arrowSize () { | |
163 | + let size = ''; | |
164 | + | |
165 | + if (this.$IVIEW) { | |
166 | + if (this.$IVIEW.tree.arrowSize) { | |
167 | + size = this.$IVIEW.tree.arrowSize; | |
168 | + } | |
169 | + } | |
170 | + return size; | |
130 | 171 | } |
131 | 172 | }, |
132 | 173 | methods: { |
... | ... | @@ -134,6 +175,9 @@ |
134 | 175 | const item = this.data; |
135 | 176 | if (item.disabled) return; |
136 | 177 | |
178 | + // Vue.js 2.6.9 对 transition 的 appear 进行了调整,导致 iView 初始化时无动画,加此方法来判断通过点击箭头展开时,加 appear,否则初始渲染时 appear 为 false | |
179 | + this.appearByClickArrow = true; | |
180 | + | |
137 | 181 | // async loading |
138 | 182 | if (item[this.childrenKey].length === 0) { |
139 | 183 | const tree = findComponentUpward(this, 'Tree'); | ... | ... |
src/index.js
... | ... | @@ -183,6 +183,11 @@ const install = function(Vue, opts = {}) { |
183 | 183 | arrow: opts.menu ? opts.menu.arrow ? opts.menu.arrow : '' : '', |
184 | 184 | customArrow: opts.menu ? opts.menu.customArrow ? opts.menu.customArrow : '' : '', |
185 | 185 | arrowSize: opts.menu ? opts.menu.arrowSize ? opts.menu.arrowSize : '' : '' |
186 | + }, | |
187 | + tree: { | |
188 | + arrow: opts.tree ? opts.tree.arrow ? opts.tree.arrow : '' : '', | |
189 | + customArrow: opts.tree ? opts.tree.customArrow ? opts.tree.customArrow : '' : '', | |
190 | + arrowSize: opts.tree ? opts.tree.arrowSize ? opts.tree.arrowSize : '' : '' | |
186 | 191 | } |
187 | 192 | }; |
188 | 193 | ... | ... |