[bugfix] Field: label slot not work (#2872)

This commit is contained in:
neverland 2019-02-28 19:41:34 +08:00 committed by GitHub
parent 33e6f2265e
commit b99d7f9c06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View File

@ -216,7 +216,7 @@ export default sfc({
icon: this.renderLeftIcon icon: this.renderLeftIcon
}; };
if (slots('label')) { if (slots('label')) {
scopedSlots.label = () => slots('title'); scopedSlots.title = () => slots('label');
} }
return ( return (

View File

@ -17,6 +17,15 @@ exports[`clearable 2`] = `
</div> </div>
`; `;
exports[`render label slot 1`] = `
<div class="van-cell van-field">
<div class="van-cell__title van-field__label">Custom Label</div>
<div class="van-cell__value">
<div class="van-field__body"><input type="text" class="van-field__control"></div>
</div>
</div>
`;
exports[`render textarea 1`] = ` exports[`render textarea 1`] = `
<div class="van-cell van-field"> <div class="van-cell van-field">
<div class="van-cell__value van-cell__value--alone"> <div class="van-cell__value van-cell__value--alone">

View File

@ -163,3 +163,18 @@ test('clearable', () => {
expect(wrapper.emitted('input')[0][0]).toEqual(''); expect(wrapper.emitted('input')[0][0]).toEqual('');
expect(wrapper.emitted('clear')).toBeTruthy(); expect(wrapper.emitted('clear')).toBeTruthy();
}); });
test('render label slot', () => {
const wrapper = mount({
template: `
<field label="Default Label">
<template v-slot:label>Custom Label</template>
</field>
`,
components: {
Field
}
});
expect(wrapper).toMatchSnapshot();
});