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