mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] Collapse: scopedSlots
This commit is contained in:
parent
2d63e0497b
commit
acc60d3266
@ -96,7 +96,10 @@ export default sfc({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { parent } = this;
|
const { parent } = this;
|
||||||
const name = parent.accordion && this.currentName === parent.value ? '' : this.currentName;
|
const name =
|
||||||
|
parent.accordion && this.currentName === parent.value
|
||||||
|
? ''
|
||||||
|
: this.currentName;
|
||||||
const expanded = !this.expanded;
|
const expanded = !this.expanded;
|
||||||
this.parent.switch(name, expanded);
|
this.parent.switch(name, expanded);
|
||||||
},
|
},
|
||||||
@ -111,15 +114,28 @@ export default sfc({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render(h) {
|
render(h) {
|
||||||
|
const titleSlots = CELL_SLOTS.reduce(
|
||||||
|
(slots, name) => {
|
||||||
|
if (this.slots(name)) {
|
||||||
|
slots[name] = () => this.slots(name);
|
||||||
|
}
|
||||||
|
return slots;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => this.slots('value')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const Title = (
|
const Title = (
|
||||||
<Cell
|
<Cell
|
||||||
class={bem('title', { disabled: this.disabled, expanded: this.expanded })}
|
class={bem('title', {
|
||||||
|
disabled: this.disabled,
|
||||||
|
expanded: this.expanded
|
||||||
|
})}
|
||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
|
scopedSlots={titleSlots}
|
||||||
{...{ props: this.$props }}
|
{...{ props: this.$props }}
|
||||||
>
|
/>
|
||||||
{this.slots('value')}
|
|
||||||
{CELL_SLOTS.map(slot => h('template', { slot }, this.slots(slot)))}
|
|
||||||
</Cell>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const Content = this.inited && (
|
const Content = this.inited && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user