From df06b0290be64b291fa39b2f81c927e3e3bc833b Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Thu, 22 Feb 2018 12:07:37 +0800
Subject: [PATCH] fix
---
components/vc-menu/MenuItem.vue | 2 +-
components/vc-menu/SubMenu.vue | 2 +-
components/vc-menu/commonPropsType.js | 10 +--
components/vc-select/Select.vue | 3 +-
components/vc-select/demo/single.vue | 100 ++++++++++++++++++++++++++
components/vc-select/demo/suggest.vue | 66 +++++++++++++++++
components/vc-select/util.js | 2 +-
7 files changed, 175 insertions(+), 10 deletions(-)
create mode 100644 components/vc-select/demo/single.vue
create mode 100644 components/vc-select/demo/suggest.vue
diff --git a/components/vc-menu/MenuItem.vue b/components/vc-menu/MenuItem.vue
index 60afb9550..abc767f22 100644
--- a/components/vc-menu/MenuItem.vue
+++ b/components/vc-menu/MenuItem.vue
@@ -5,7 +5,7 @@ import KeyCode from '../_util/KeyCode'
import BaseMixin from '../_util/BaseMixin'
const props = {
rootPrefixCls: PropTypes.string,
- eventKey: PropTypes.string,
+ eventKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
active: PropTypes.bool,
selectedKeys: PropTypes.array,
disabled: PropTypes.bool,
diff --git a/components/vc-menu/SubMenu.vue b/components/vc-menu/SubMenu.vue
index 1dd425b27..f42d8ce25 100644
--- a/components/vc-menu/SubMenu.vue
+++ b/components/vc-menu/SubMenu.vue
@@ -26,7 +26,7 @@ export default {
openKeys: PropTypes.array.def([]),
openChange: PropTypes.func.def(noop),
rootPrefixCls: PropTypes.string,
- eventKey: PropTypes.string,
+ eventKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
multiple: PropTypes.bool,
active: PropTypes.bool, // TODO: remove
isRootMenu: PropTypes.bool,
diff --git a/components/vc-menu/commonPropsType.js b/components/vc-menu/commonPropsType.js
index 3d678e313..039efe2d5 100644
--- a/components/vc-menu/commonPropsType.js
+++ b/components/vc-menu/commonPropsType.js
@@ -5,11 +5,11 @@ export default {
multiple: PropTypes.bool,
defaultActiveFirst: PropTypes.bool,
visible: PropTypes.bool.def(true),
- activeKey: PropTypes.string,
- selectedKeys: PropTypes.arrayOf(PropTypes.string),
- defaultSelectedKeys: PropTypes.arrayOf(PropTypes.string).def([]),
- defaultOpenKeys: PropTypes.arrayOf(PropTypes.string).def([]),
- openKeys: PropTypes.arrayOf(PropTypes.string),
+ activeKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ selectedKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
+ defaultSelectedKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).def([]),
+ defaultOpenKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).def([]),
+ openKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
openAnimation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']).def('vertical'),
triggerSubMenuAction: PropTypes.string.def('hover'),
diff --git a/components/vc-select/Select.vue b/components/vc-select/Select.vue
index 7ec9e2b9c..0067009b4 100644
--- a/components/vc-select/Select.vue
+++ b/components/vc-select/Select.vue
@@ -210,7 +210,6 @@ export default {
},
onDropdownVisibleChange (open) {
- console.log('onDropdownVisibleChange', open)
if (open && !this._focused) {
this.clearBlurTime()
this.timeoutFocus()
@@ -558,7 +557,7 @@ export default {
},
getLabelFromProps (value) {
- return this.getLabelByValue(this.$slots.default, value)
+ return this.getLabelByValue(this.$slots.default || [], value)
},
getVLForOnChange (vls_) {
diff --git a/components/vc-select/demo/single.vue b/components/vc-select/demo/single.vue
new file mode 100644
index 000000000..ccbabd09f
--- /dev/null
+++ b/components/vc-select/demo/single.vue
@@ -0,0 +1,100 @@
+
diff --git a/components/vc-select/demo/suggest.vue b/components/vc-select/demo/suggest.vue
new file mode 100644
index 000000000..c18fa2571
--- /dev/null
+++ b/components/vc-select/demo/suggest.vue
@@ -0,0 +1,66 @@
+
diff --git a/components/vc-select/util.js b/components/vc-select/util.js
index 88fa5de5e..7569640f6 100644
--- a/components/vc-select/util.js
+++ b/components/vc-select/util.js
@@ -4,7 +4,7 @@ export function getValuePropValue (child) {
if ('value' in props) {
return props.value
}
- if (getKey(child)) {
+ if (getKey(child) !== undefined) {
return getKey(child)
}
if (getSlotOptions(child).isSelectOptGroup && props.label) {