Commit 47afd12e3fb854d8f796575911351f6738d57ebc
1 parent
bbc31581
Cascader add gloabl setting, #5592 , close #5597
Showing
4 changed files
with
86 additions
and
4 deletions
Show diff stats
src/components/cascader/cascader.vue
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | v-show="filterable && query === ''" |
18 | 18 | @click="handleFocus">{{ displayRender }}</div> |
19 | 19 | <Icon type="ios-close-circle" :class="[prefixCls + '-arrow']" v-show="showCloseIcon" @click.native.stop="clearSelect"></Icon> |
20 | - <Icon type="ios-arrow-down" :class="[prefixCls + '-arrow']"></Icon> | |
20 | + <Icon :type="arrowType" :custom="customArrowType" :size="arrowSize" :class="[prefixCls + '-arrow']"></Icon> | |
21 | 21 | </slot> |
22 | 22 | </div> |
23 | 23 | <transition name="transition-drop"> |
... | ... | @@ -232,6 +232,41 @@ |
232 | 232 | return item; |
233 | 233 | }); |
234 | 234 | return selections; |
235 | + }, | |
236 | + // 3.4.0, global setting customArrow 有值时,arrow 赋值空 | |
237 | + arrowType () { | |
238 | + let type = 'ios-arrow-down'; | |
239 | + | |
240 | + if (this.$IVIEW) { | |
241 | + if (this.$IVIEW.cascader.customArrow) { | |
242 | + type = ''; | |
243 | + } else if (this.$IVIEW.cascader.arrow) { | |
244 | + type = this.$IVIEW.cascader.arrow; | |
245 | + } | |
246 | + } | |
247 | + return type; | |
248 | + }, | |
249 | + // 3.4.0, global setting | |
250 | + customArrowType () { | |
251 | + let type = ''; | |
252 | + | |
253 | + if (this.$IVIEW) { | |
254 | + if (this.$IVIEW.cascader.customArrow) { | |
255 | + type = this.$IVIEW.cascader.customArrow; | |
256 | + } | |
257 | + } | |
258 | + return type; | |
259 | + }, | |
260 | + // 3.4.0, global setting | |
261 | + arrowSize () { | |
262 | + let size = ''; | |
263 | + | |
264 | + if (this.$IVIEW) { | |
265 | + if (this.$IVIEW.cascader.arrowSize) { | |
266 | + size = this.$IVIEW.cascader.arrowSize; | |
267 | + } | |
268 | + } | |
269 | + return size; | |
235 | 270 | } |
236 | 271 | }, |
237 | 272 | methods: { | ... | ... |
src/components/cascader/casitem.vue
1 | 1 | <template> |
2 | 2 | <li :class="classes"> |
3 | 3 | {{ data.label }} |
4 | - <i v-if="showArrow" class="ivu-icon ivu-icon-ios-arrow-forward"></i> | |
4 | + <Icon :type="arrowType" :custom="customArrowType" :size="arrowSize" v-if="showArrow" /> | |
5 | 5 | <i v-if="showLoading" class="ivu-icon ivu-icon-ios-loading ivu-load-loop"></i> |
6 | 6 | </li> |
7 | 7 | </template> |
8 | 8 | <script> |
9 | + import Icon from '../icon/icon.vue'; | |
10 | + | |
9 | 11 | export default { |
10 | 12 | name: 'Casitem', |
13 | + components: { Icon }, | |
11 | 14 | props: { |
12 | 15 | data: Object, |
13 | 16 | prefixCls: String, |
... | ... | @@ -28,6 +31,41 @@ |
28 | 31 | }, |
29 | 32 | showLoading () { |
30 | 33 | return 'loading' in this.data && this.data.loading; |
34 | + }, | |
35 | + // 3.4.0, global setting customArrow 有值时,arrow 赋值空 | |
36 | + arrowType () { | |
37 | + let type = 'ios-arrow-forward'; | |
38 | + | |
39 | + if (this.$IVIEW) { | |
40 | + if (this.$IVIEW.cascader.customItemArrow) { | |
41 | + type = ''; | |
42 | + } else if (this.$IVIEW.cascader.itemArrow) { | |
43 | + type = this.$IVIEW.cascader.itemArrow; | |
44 | + } | |
45 | + } | |
46 | + return type; | |
47 | + }, | |
48 | + // 3.4.0, global setting | |
49 | + customArrowType () { | |
50 | + let type = ''; | |
51 | + | |
52 | + if (this.$IVIEW) { | |
53 | + if (this.$IVIEW.cascader.customItemArrow) { | |
54 | + type = this.$IVIEW.cascader.customItemArrow; | |
55 | + } | |
56 | + } | |
57 | + return type; | |
58 | + }, | |
59 | + // 3.4.0, global setting | |
60 | + arrowSize () { | |
61 | + let size = ''; | |
62 | + | |
63 | + if (this.$IVIEW) { | |
64 | + if (this.$IVIEW.cascader.itemArrowSize) { | |
65 | + size = this.$IVIEW.cascader.itemArrowSize; | |
66 | + } | |
67 | + } | |
68 | + return size; | |
31 | 69 | } |
32 | 70 | } |
33 | 71 | }; | ... | ... |
src/index.js
... | ... | @@ -188,6 +188,14 @@ const install = function(Vue, opts = {}) { |
188 | 188 | arrow: opts.tree ? opts.tree.arrow ? opts.tree.arrow : '' : '', |
189 | 189 | customArrow: opts.tree ? opts.tree.customArrow ? opts.tree.customArrow : '' : '', |
190 | 190 | arrowSize: opts.tree ? opts.tree.arrowSize ? opts.tree.arrowSize : '' : '' |
191 | + }, | |
192 | + cascader: { | |
193 | + arrow: opts.cascader ? opts.cascader.arrow ? opts.cascader.arrow : '' : '', | |
194 | + customArrow: opts.cascader ? opts.cascader.customArrow ? opts.cascader.customArrow : '' : '', | |
195 | + arrowSize: opts.cascader ? opts.cascader.arrowSize ? opts.cascader.arrowSize : '' : '', | |
196 | + itemArrow: opts.cascader ? opts.cascader.itemArrow ? opts.cascader.itemArrow : '' : '', | |
197 | + customItemArrow: opts.cascader ? opts.cascader.customItemArrow ? opts.cascader.customItemArrow : '' : '', | |
198 | + itemArrowSize: opts.cascader ? opts.cascader.itemArrowSize ? opts.cascader.itemArrowSize : '' : '' | |
191 | 199 | } |
192 | 200 | }; |
193 | 201 | ... | ... |
src/styles/components/cascader.less
... | ... | @@ -68,7 +68,7 @@ |
68 | 68 | .inner-arrow(); |
69 | 69 | } |
70 | 70 | &-visible &-arrow:nth-of-type(2) { |
71 | - transform: rotate(180deg); | |
71 | + transform: translateY(-50%) rotate(180deg); | |
72 | 72 | } |
73 | 73 | |
74 | 74 | .@{select-dropdown-prefix-cls} { |
... | ... | @@ -134,7 +134,8 @@ |
134 | 134 | position: absolute; |
135 | 135 | right: 15px; |
136 | 136 | top: 50%; |
137 | - margin-top: -6px; | |
137 | + //margin-top: -6px; | |
138 | + transform: translateY(-50%); | |
138 | 139 | } |
139 | 140 | |
140 | 141 | &-active{ | ... | ... |