Commit 5557dd66f52516088e8b3e19f1678691f610bb6a
1 parent
745bcbc2
update Dropdown
update Dropdown
Showing
3 changed files
with
14 additions
and
5 deletions
Show diff stats
src/components/dropdown/dropdown-item.vue
@@ -36,16 +36,18 @@ | @@ -36,16 +36,18 @@ | ||
36 | }, | 36 | }, |
37 | methods: { | 37 | methods: { |
38 | handleClick () { | 38 | handleClick () { |
39 | + const $parent = this.$parent.$parent; | ||
39 | if (this.disabled) { | 40 | if (this.disabled) { |
40 | this.$nextTick(() => { | 41 | this.$nextTick(() => { |
41 | - this.$parent.$parent.visible = true; | 42 | + $parent.visible = true; |
42 | }); | 43 | }); |
43 | } else { | 44 | } else { |
44 | - if (this.$parent.$parent.trigger === 'hover') { | ||
45 | - this.$parent.$parent.visible = false; | 45 | + if ($parent.trigger === 'hover') { |
46 | + $parent.visible = false; | ||
47 | + $parent.$emit('on-hover-click'); | ||
46 | } | 48 | } |
47 | } | 49 | } |
48 | - this.$parent.$parent.$emit('on-click', this.key); | 50 | + $parent.$emit('on-click', this.key); |
49 | } | 51 | } |
50 | } | 52 | } |
51 | } | 53 | } |
src/components/dropdown/dropdown.vue
@@ -87,6 +87,13 @@ | @@ -87,6 +87,13 @@ | ||
87 | if ($parent && $parent.$options.name === 'Dropdown') { | 87 | if ($parent && $parent.$options.name === 'Dropdown') { |
88 | $parent.$emit('on-click', key); | 88 | $parent.$emit('on-click', key); |
89 | } | 89 | } |
90 | + }, | ||
91 | + 'on-hover-click' () { | ||
92 | + const $parent = this.$parent.$parent; | ||
93 | + if ($parent && $parent.$options.name === 'Dropdown') { | ||
94 | + $parent.visible = false; | ||
95 | + $parent.$emit('on-hover-click'); | ||
96 | + } | ||
90 | } | 97 | } |
91 | } | 98 | } |
92 | } | 99 | } |
test/routers/dropdown.vue
1 | <template> | 1 | <template> |
2 | - <Dropdown trigger="click" @on-click="click" style="margin-left: 20px"> | 2 | + <Dropdown trigger="hover" @on-click="click" style="margin-left: 20px"> |
3 | <a href="javascript:void(0)"> | 3 | <a href="javascript:void(0)"> |
4 | click 触发 | 4 | click 触发 |
5 | <Icon type="arrow-down-b"></Icon> | 5 | <Icon type="arrow-down-b"></Icon> |