From be16a493d0c6935150bb9e5ca7f879f8ee4d6e29 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 17 Jan 2022 10:31:49 +0800 Subject: [PATCH] feat(Cascader): add show-header prop (#10201) --- src/cascader/README.md | 1 + src/cascader/README.zh-CN.md | 1 + src/cascader/index.js | 30 ++++++++++++++++++------------ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/cascader/README.md b/src/cascader/README.md index 754a6a7c7..c7832316e 100644 --- a/src/cascader/README.md +++ b/src/cascader/README.md @@ -184,6 +184,7 @@ export default { | placeholder | Placeholder of unselected tab | _string_ | `Select` | | active-color | Active color | _string_ | `#ee0a24` | | closeable | Whether to show close icon | _boolean_ | `true` | +| show-header `v2.12.40` | Whether to show header | _boolean_ | `true` | | field-names `v2.12.4` | Custom the fields of options | _object_ | `{ text: 'text', value: 'value', children: 'children' }` | ### Events diff --git a/src/cascader/README.zh-CN.md b/src/cascader/README.zh-CN.md index 31733f24a..ac3970c8a 100644 --- a/src/cascader/README.zh-CN.md +++ b/src/cascader/README.zh-CN.md @@ -198,6 +198,7 @@ export default { | placeholder | 未选中时的提示文案 | _string_ | `请选择` | | active-color | 选中状态的高亮颜色 | _string_ | `#ee0a24` | | closeable | 是否显示关闭图标 | _boolean_ | `true` | +| show-header `v2.12.40` | 是否展示标题栏 | _boolean_ | `true` | | field-names `v2.12.4` | 自定义 `options` 结构中的字段 | _object_ | `{ text: 'text', value: 'value', children: 'children' }` | ### Events diff --git a/src/cascader/index.js b/src/cascader/index.js index 7d497660d..4c997113c 100644 --- a/src/cascader/index.js +++ b/src/cascader/index.js @@ -20,6 +20,10 @@ export default createComponent({ type: Boolean, default: true, }, + showHeader: { + type: Boolean, + default: true, + }, }, data() { @@ -180,18 +184,20 @@ export default createComponent({ }, renderHeader() { - return ( -
-

{this.slots('title') || this.title}

- {this.closeable ? ( - - ) : null} -
- ); + if (this.showHeader) { + return ( +
+

{this.slots('title') || this.title}

+ {this.closeable ? ( + + ) : null} +
+ ); + } }, renderOptions(options, selectedOption, tabIndex) {