feat(Cascader): add show-header prop (#10201)

This commit is contained in:
neverland 2022-01-17 10:31:49 +08:00 committed by GitHub
parent e3238d8fa1
commit be16a493d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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 (
<div class={bem('header')}>
<h2 class={bem('title')}>{this.slots('title') || this.title}</h2>
{this.closeable ? (
<Icon
name="cross"
class={bem('close-icon')}
onClick={this.onClose}
/>
) : null}
</div>
);
if (this.showHeader) {
return (
<div class={bem('header')}>
<h2 class={bem('title')}>{this.slots('title') || this.title}</h2>
{this.closeable ? (
<Icon
name="cross"
class={bem('close-icon')}
onClick={this.onClose}
/>
) : null}
</div>
);
}
},
renderOptions(options, selectedOption, tabIndex) {