From 257a050ba9aa2a35724237f0c2d8ddd2f305b24b Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 22 Feb 2018 17:19:47 +0800 Subject: [PATCH] fix --- components/align/Align.vue | 5 +- components/trigger/Popup.vue | 8 +++- components/vc-select/Select.vue | 25 +++++++--- components/vc-select/demo/single.vue | 4 +- components/vc-select/demo/tags.vue | 70 ++++++++++++++++++++++++++++ components/vc-select/util.js | 5 +- examples/routes.js | 2 +- 7 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 components/vc-select/demo/tags.vue diff --git a/components/align/Align.vue b/components/align/Align.vue index 8e4e4e794..9ca83a79e 100644 --- a/components/align/Align.vue +++ b/components/align/Align.vue @@ -36,6 +36,7 @@ export default { monitorBufferTime: PropTypes.number.def(50), monitorWindowResize: PropTypes.bool.def(false), disabled: PropTypes.bool.def(false), + visible: PropTypes.bool.def(false), }, data () { this.aligned = false @@ -55,8 +56,8 @@ export default { const prevProps = this.prevProps const props = this.$props let reAlign = false - if (!props.disabled) { - if (prevProps.disabled || !isEqual(prevProps.align, props.align)) { + if (!props.disabled && this.visible) { + if (prevProps.disabled || prevProps.align !== props.align) { reAlign = true } else { const lastTarget = prevProps.target() diff --git a/components/trigger/Popup.vue b/components/trigger/Popup.vue index 7424f596a..465e0655f 100644 --- a/components/trigger/Popup.vue +++ b/components/trigger/Popup.vue @@ -129,10 +129,13 @@ export default { const transitionEvent = { beforeEnter: (el) => { el.style.display = el.__vOriginalDisplay - this.$refs.alignInstance.forceAlign() + // this.$refs.alignInstance.forceAlign() }, enter: (el, done) => { - animate(el, `${transitionName}-enter`, done) + // align updated后执行动画 + this.$nextTick(() => { + animate(el, `${transitionName}-enter`, done) + }) }, leave: (el, done) => { animate(el, `${transitionName}-leave`, done) @@ -169,6 +172,7 @@ export default { monitorWindowResize align={align} onAlign={this.onAlign} + visible={visible} > 0) { this._valueOptions = this.getOptionsByValue(sValue) } + console.log(sValue) return { sValue, inputValue, @@ -166,11 +167,23 @@ export default { } }, methods: { - updateLabelAndTitleMap () { - const labelMap = {} - const titleMap = {} - this.labelMap = labelMap - this.titleMap = titleMap + updateLabelAndTitleMap (children = []) { + this.titleMap = {} + this.updateTitleMap(this.$slots.default) + }, + updateTitleMap (children = []) { + children.forEach(child => { + if (!child) { + return + } + if (getSlotOptions(child).isSelectOptGroup) { + this.updateTitleMap(child.componentOptions.children) + } else { + const key = getValuePropValue(child) + this.titleMap[key] = getValue(child, 'title') + this.labelMap[key] = this.getLabelFromOption(child) + } + }) }, updateState () { const { combobox, $slots } = this diff --git a/components/vc-select/demo/single.vue b/components/vc-select/demo/single.vue index ccbabd09f..155be8635 100644 --- a/components/vc-select/demo/single.vue +++ b/components/vc-select/demo/single.vue @@ -6,7 +6,7 @@ export default { data () { return { destroy: false, - value: '01', + value: 'hello', } }, methods: { @@ -58,7 +58,7 @@ export default { firstActiveValue='2' backfill > -