Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 7x 7x 7x 23387x 23387x 23387x 23387x 23387x 2002x 2002x 1987x 1987x 1987x 2347x 2347x | <script>
export default {
name: 'f-slot',
functional: true,
props: {
vm: null,
name: String,
props: Object,
catchError: { type: Boolean, default: true },
},
render(h, context) {
let { vm, name, props, catchError } = context.props;
vm = vm || vm.context.parent; // @TODO: 可能不太对,需要验证一下
const scopedSlot = vm.$scopedSlots[name];
const slot = vm.$slots[name];
if (scopedSlot) {
try {
const slotResult = scopedSlot(props);
if (slotResult) {
const newScopeValue = [];
(slotResult || []).forEach((scopeValue) => {
if (scopeValue.tag !== vm.$vnode.tag) {
newScopeValue.push(scopeValue);
}
});
return newScopeValue;
} else
return context.children;
} catch (e) {
if (catchError)
return h('div', e.message || e);
else
throw e;
}
} else if (slot)
return slot;
else
return context.children;
},
};E
</script>
|