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 [name, bem] = createNamespace('collapse-item');
const CELL_SLOTS = ['icon', 'title', 'value', 'label', 'right-icon'] as const;
export default defineComponent({ export default defineComponent({
name, name,
@ -112,12 +114,7 @@ export default defineComponent({
return ( return (
<Cell <Cell
v-slots={{ v-slots={pick(slots, CELL_SLOTS)}
icon: slots.icon,
title: slots.title,
default: slots.value,
'right-icon': slots['right-icon'],
}}
role="button" role="button"
class={bem('title', { class={bem('title', {
disabled, disabled,

View File

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

View File

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

View File

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

View File

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