feat(Area): add title slot (#5719)

This commit is contained in:
chenjiahan
2020-02-25 19:20:29 +08:00
parent a5acd379f7
commit 7344389535
6 changed files with 61 additions and 1 deletions
+16
View File
@@ -10,6 +10,21 @@ function isOverseaCode(code) {
return code[0] === '9';
}
function pickSlots(instance, keys) {
const { $slots, $scopedSlots } = instance;
const scopedSlots = {};
keys.forEach(key => {
if ($scopedSlots[key]) {
scopedSlots[key] = $scopedSlots[key];
} else if ($slots[key]) {
scopedSlots[key] = () => $slots[key];
}
});
return scopedSlots;
}
export default createComponent({
props: {
...pickerProps,
@@ -290,6 +305,7 @@ export default createComponent({
visibleItemCount={this.visibleItemCount}
cancelButtonText={this.cancelButtonText}
confirmButtonText={this.confirmButtonText}
scopedSlots={pickSlots(this, ['title'])}
{...{ on }}
/>
);