From 51f9f894eb317be59ee513cf9255db9b1a064985 Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Fri, 13 Jan 2017 11:32:56 +0800 Subject: [PATCH] Dropdown add custom and visible prop --- src/components/dropdown/dropdown.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/dropdown/dropdown.vue b/src/components/dropdown/dropdown.vue index 8eecd8d..98a739c 100644 --- a/src/components/dropdown/dropdown.vue +++ b/src/components/dropdown/dropdown.vue @@ -22,7 +22,7 @@ props: { trigger: { validator (value) { - return oneOf(value, ['click', 'hover']); + return oneOf(value, ['click', 'hover', 'custom']); }, default: 'hover' }, @@ -31,6 +31,10 @@ return oneOf(value, ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']); }, default: 'bottom' + }, + visible: { + type: Boolean, + default: false } }, computed: { @@ -40,18 +44,19 @@ }, data () { return { - prefixCls: prefixCls, - visible: false + prefixCls: prefixCls }; }, methods: { handleClick () { + if (this.trigger === 'custom') return false; if (this.trigger !== 'click') { return false; } this.visible = !this.visible; }, handleMouseenter () { + if (this.trigger === 'custom') return false; if (this.trigger !== 'hover') { return false; } @@ -61,6 +66,7 @@ }, 250); }, handleMouseleave () { + if (this.trigger === 'custom') return false; if (this.trigger !== 'hover') { return false; } @@ -70,6 +76,7 @@ }, 150); }, handleClose () { + if (this.trigger === 'custom') return false; if (this.trigger !== 'click') { return false; } @@ -103,17 +110,20 @@ const $parent = this.hasParent(); if ($parent) { this.$nextTick(() => { + if (this.trigger === 'custom') return false; this.visible = false; }); $parent.$emit('on-hover-click'); } else { this.$nextTick(() => { + if (this.trigger === 'custom') return false; this.visible = false; }); } }, 'on-haschild-click' () { this.$nextTick(() => { + if (this.trigger === 'custom') return false; this.visible = true; }); const $parent = this.hasParent(); -- libgit2 0.21.4