feat(CollapseItem): add label slot (#8934)

* feat(CollapseItem): add label slot

* docs: upd
This commit is contained in:
neverland 2021-06-26 21:43:00 +08:00 committed by GitHub
parent 29f800b827
commit 12400a2527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 21 deletions

View File

@ -15,6 +15,8 @@ import { Cell } from '../cell';
const [name, bem] = createNamespace('collapse-item');
const CELL_SLOTS = ['icon', 'title', 'value', 'label', 'right-icon'] as const;
export default defineComponent({
name,
@ -112,12 +114,7 @@ export default defineComponent({
return (
<Cell
v-slots={{
icon: slots.icon,
title: slots.title,
default: slots.value,
'right-icon': slots['right-icon'],
}}
v-slots={pick(slots, CELL_SLOTS)}
role="button"
class={bem('title', {
disabled,

View File

@ -144,13 +144,14 @@ export default {
### CollapseItem Slots
| Name | Description |
| ---------- | ----------------- |
| default | Content |
| value | Custom value |
| icon | Custom icon |
| title | Custom title |
| right-icon | Custom right icon |
| Name | Description |
| -------------- | ------------------------ |
| default | Content |
| title | Custom header title |
| value | Custom header value |
| label `v3.1.1` | Custom header label |
| icon | Custom header left icon |
| right-icon | Custom header right icon |
### CollapseItem Methods

View File

@ -142,13 +142,14 @@ export default {
### CollapseItem Slots
| 名称 | 说明 |
| ---------- | ------------------------------ |
| default | 面板内容 |
| value | 自定义显示内容 |
| icon | 自定义 `icon` |
| title | 自定义 `title` |
| right-icon | 自定义右侧按钮,默认是 `arrow` |
| 名称 | 说明 |
| -------------- | -------------------- |
| default | 面板内容 |
| title | 自定义标题栏左侧内容 |
| value | 自定义标题栏右侧内容 |
| label `v3.1.1` | 自定义标题栏描述信息 |
| icon | 自定义标题栏左侧图标 |
| right-icon | 自定义标题栏右侧图标 |
### CollapseItem 方法

View File

@ -11,6 +11,9 @@ exports[`should render slots of CollapseItem correctly 1`] = `
this is icon
<div class="van-cell__title">
this is title
<div class="van-cell__label">
this is label
</div>
</div>
<div class="van-cell__value">
this is value

View File

@ -85,9 +85,10 @@ test('should render slots of CollapseItem correctly', () => {
<Collapse v-model={this.active}>
<CollapseItem
v-slots={{
icon: () => 'this is icon',
title: () => 'this is title',
value: () => 'this is value',
icon: () => 'this is icon',
label: () => 'this is label',
'right-icon': () => 'this is right icon',
}}
/>