Signed-off-by: lixingchi1 <lixingchi1@huawei.com>
This commit is contained in:
lixingchi1
2022-01-13 16:45:18 +08:00
parent 70f539cabd
commit 7dfc932949
+10
View File
@@ -80,6 +80,7 @@ export interface AttrInterface {
tid: number;
append: string;
slot: string;
slotScope: string;
name: string;
data: () => any | string;
$data: () => any | string;
@@ -316,6 +317,15 @@ function compileSlot(vm: Vm, target: TemplateInterface, dest: Element): Element
if (!namedContent) {
compileChildren(vm, slotItem.target, slotItem.dest);
} else {
// Bind slot scope
if (Array.isArray(namedContent)) {
namedContent.forEach((item: TemplateInterface) => {
const slotScope = item.attr && item.attr.slotScope;
if (typeof slotScope === 'string') {
parentVm[slotScope] = vm._data;
}
});
}
compileChildren(parentVm, { children: namedContent }, slotItem.dest);
}
}