diff --git a/examples/docs/en-US/cascader.md b/examples/docs/en-US/cascader.md index fafd65ad2..3eb74a6f2 100644 --- a/examples/docs/en-US/cascader.md +++ b/examples/docs/en-US/cascader.md @@ -473,7 +473,7 @@ Search and select options directly. |---------- |-------------------- |---------|------------- |-------- | | options | data source of the options | array | — | — | | value | selected value | array | — | — | -| popup-class | className of popup overlay | string | — | — | +| popper-class | className of popup overlay | string | — | — | | placeholder | input placeholder | string | — | — | | disabled | 是否禁用 | boolean | — | false | | clearable | whether allow clear | boolean | — | false | diff --git a/examples/docs/zh-CN/cascader.md b/examples/docs/zh-CN/cascader.md index db3f1d599..7281daca5 100644 --- a/examples/docs/zh-CN/cascader.md +++ b/examples/docs/zh-CN/cascader.md @@ -477,7 +477,7 @@ |---------- |-------- |---------- |------------- |-------- | | options | 可选项数据源 | array | — | — | | value | 指定选中项 | array | — | — | -| popup-class | 自定义浮层类名 | string | — | — | +| popper-class | 自定义浮层类名 | string | — | — | | placeholder | 输入框占位文本 | string | — | — | | disabled | 是否禁用 | boolean | — | false | | clearable | 是否支持清除 | boolean | — | false | diff --git a/examples/docs/zh-CN/select.md b/examples/docs/zh-CN/select.md index 2dda85d93..124481c4b 100644 --- a/examples/docs/zh-CN/select.md +++ b/examples/docs/zh-CN/select.md @@ -215,7 +215,7 @@ value: '选项5', label: '北京烤鸭' }], - value2: '选项2' + value2: '' } } } diff --git a/packages/cascader/src/main.vue b/packages/cascader/src/main.vue index 12949fe3c..d96ea3ae0 100644 --- a/packages/cascader/src/main.vue +++ b/packages/cascader/src/main.vue @@ -146,6 +146,7 @@ export default { this.menu.value = this.currentValue.slice(0); this.menu.visible = true; + this.menu.options = this.options; this.menu.$on('pick', this.handlePick); this.updatePopper(); this.$nextTick(_ => { @@ -153,18 +154,20 @@ export default { }); }, hideMenu() { - this.menu.visible = false; this.inputValue = ''; + this.menu.visible = false; }, handlePick(value, close = true) { this.currentValue = value; this.$emit('input', value); this.$emit('change', value); + if (close) { this.menuVisible = false; } }, handleInputChange(value) { + if (!this.menuVisible) return; const flatOptions = this.flatOptions; if (!value) { @@ -228,9 +231,12 @@ export default { this.menuVisible = false; }, handleClick() { - if (!this.disabled) { - this.menuVisible = !this.menuVisible; + if (this.disabled) return; + if (this.filterable) { + this.menuVisible = true; + return; } + this.menuVisible = !this.menuVisible; } } }; diff --git a/packages/cascader/src/menu.vue b/packages/cascader/src/menu.vue index 509e3dc23..ab864df5f 100644 --- a/packages/cascader/src/menu.vue +++ b/packages/cascader/src/menu.vue @@ -34,7 +34,6 @@ cache: false, get() { const activeValue = this.activeValue; - let options = this.options; const loadActiveOptions = (options, activeOptions = []) => { const level = activeOptions.length; @@ -49,9 +48,7 @@ return activeOptions; }; - const result = loadActiveOptions(options); - - return result; + return loadActiveOptions(this.options); } } },