mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix template slot
This commit is contained in:
parent
acc60d3266
commit
b74fe6fffc
@ -211,6 +211,14 @@ export default sfc({
|
|||||||
|
|
||||||
render(h) {
|
render(h) {
|
||||||
const { slots, labelAlign } = this;
|
const { slots, labelAlign } = this;
|
||||||
|
|
||||||
|
const scopedSlots = {
|
||||||
|
icon: this.renderLeftIcon
|
||||||
|
};
|
||||||
|
if (slots('label')) {
|
||||||
|
scopedSlots.label = () => slots('title');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
icon={this.leftIcon}
|
icon={this.leftIcon}
|
||||||
@ -226,11 +234,8 @@ export default sfc({
|
|||||||
[`label-${labelAlign}`]: labelAlign,
|
[`label-${labelAlign}`]: labelAlign,
|
||||||
'min-height': this.type === 'textarea' && !this.autosize
|
'min-height': this.type === 'textarea' && !this.autosize
|
||||||
})}
|
})}
|
||||||
scopedSlots={{
|
scopedSlots={scopedSlots}
|
||||||
icon: this.renderLeftIcon
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{h('template', { slot: 'title' }, slots('label'))}
|
|
||||||
<div class={bem('body')}>
|
<div class={bem('body')}>
|
||||||
{this.renderInput()}
|
{this.renderInput()}
|
||||||
{this.showClear && <Icon name="clear" class={bem('clear')} onTouchstart={this.onClear} />}
|
{this.showClear && <Icon name="clear" class={bem('clear')} onTouchstart={this.onClear} />}
|
||||||
|
@ -53,6 +53,11 @@ export default sfc({
|
|||||||
on: this.listeners
|
on: this.listeners
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scopedSlots = {};
|
||||||
|
if (this.slots('left-icon')) {
|
||||||
|
scopedSlots['left-icon'] = () => this.slots('left-icon');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={bem({ 'show-action': showAction })} style={{ background: this.background }}>
|
<div class={bem({ 'show-action': showAction })} style={{ background: this.background }}>
|
||||||
<Field
|
<Field
|
||||||
@ -61,9 +66,9 @@ export default sfc({
|
|||||||
value={this.value}
|
value={this.value}
|
||||||
border={false}
|
border={false}
|
||||||
leftIcon="search"
|
leftIcon="search"
|
||||||
|
scopedSlots={scopedSlots}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{h('template', { slot: 'left-icon' }, this.slots('left-icon'))}
|
|
||||||
</Field>
|
</Field>
|
||||||
{showAction && (
|
{showAction && (
|
||||||
<div class={bem('action')}>
|
<div class={bem('action')}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user