Commit 51f9f894eb317be59ee513cf9255db9b1a064985
1 parent
d509d2b2
Dropdown add custom and visible prop
Dropdown add custom and visible prop
Showing
1 changed file
with
13 additions
and
3 deletions
Show diff stats
src/components/dropdown/dropdown.vue
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | props: { |
| 23 | 23 | trigger: { |
| 24 | 24 | validator (value) { |
| 25 | - return oneOf(value, ['click', 'hover']); | |
| 25 | + return oneOf(value, ['click', 'hover', 'custom']); | |
| 26 | 26 | }, |
| 27 | 27 | default: 'hover' |
| 28 | 28 | }, |
| ... | ... | @@ -31,6 +31,10 @@ |
| 31 | 31 | return oneOf(value, ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']); |
| 32 | 32 | }, |
| 33 | 33 | default: 'bottom' |
| 34 | + }, | |
| 35 | + visible: { | |
| 36 | + type: Boolean, | |
| 37 | + default: false | |
| 34 | 38 | } |
| 35 | 39 | }, |
| 36 | 40 | computed: { |
| ... | ... | @@ -40,18 +44,19 @@ |
| 40 | 44 | }, |
| 41 | 45 | data () { |
| 42 | 46 | return { |
| 43 | - prefixCls: prefixCls, | |
| 44 | - visible: false | |
| 47 | + prefixCls: prefixCls | |
| 45 | 48 | }; |
| 46 | 49 | }, |
| 47 | 50 | methods: { |
| 48 | 51 | handleClick () { |
| 52 | + if (this.trigger === 'custom') return false; | |
| 49 | 53 | if (this.trigger !== 'click') { |
| 50 | 54 | return false; |
| 51 | 55 | } |
| 52 | 56 | this.visible = !this.visible; |
| 53 | 57 | }, |
| 54 | 58 | handleMouseenter () { |
| 59 | + if (this.trigger === 'custom') return false; | |
| 55 | 60 | if (this.trigger !== 'hover') { |
| 56 | 61 | return false; |
| 57 | 62 | } |
| ... | ... | @@ -61,6 +66,7 @@ |
| 61 | 66 | }, 250); |
| 62 | 67 | }, |
| 63 | 68 | handleMouseleave () { |
| 69 | + if (this.trigger === 'custom') return false; | |
| 64 | 70 | if (this.trigger !== 'hover') { |
| 65 | 71 | return false; |
| 66 | 72 | } |
| ... | ... | @@ -70,6 +76,7 @@ |
| 70 | 76 | }, 150); |
| 71 | 77 | }, |
| 72 | 78 | handleClose () { |
| 79 | + if (this.trigger === 'custom') return false; | |
| 73 | 80 | if (this.trigger !== 'click') { |
| 74 | 81 | return false; |
| 75 | 82 | } |
| ... | ... | @@ -103,17 +110,20 @@ |
| 103 | 110 | const $parent = this.hasParent(); |
| 104 | 111 | if ($parent) { |
| 105 | 112 | this.$nextTick(() => { |
| 113 | + if (this.trigger === 'custom') return false; | |
| 106 | 114 | this.visible = false; |
| 107 | 115 | }); |
| 108 | 116 | $parent.$emit('on-hover-click'); |
| 109 | 117 | } else { |
| 110 | 118 | this.$nextTick(() => { |
| 119 | + if (this.trigger === 'custom') return false; | |
| 111 | 120 | this.visible = false; |
| 112 | 121 | }); |
| 113 | 122 | } |
| 114 | 123 | }, |
| 115 | 124 | 'on-haschild-click' () { |
| 116 | 125 | this.$nextTick(() => { |
| 126 | + if (this.trigger === 'custom') return false; | |
| 117 | 127 | this.visible = true; |
| 118 | 128 | }); |
| 119 | 129 | const $parent = this.hasParent(); | ... | ... |