Closed skytt closed 2 years ago
I try to figure out this problem, and found that adding resolveScopedSlots
func intoafterRender
(src/utils/instance.ts
) can make the context.slots synchronized context.slots
and actual slot content, like:
export function afterRender(vm: ComponentInstance) {
+ const attrs = vmStateManager.get(vm, 'attrBindings')
+ if (attrs?.ctx.slots) {
+ resolveScopedSlots(vm, attrs.ctx.slots)
+ }
const stack = [(vm as any)._vnode as VNode]
while (stack.length) {
const vnode = stack.pop()
if (vnode) {
if (vnode.context) updateTemplateRef(vnode.context)
if (vnode.children) {
for (let i = 0; i < vnode.children.length; ++i) {
stack.push(vnode.children[i])
}
}
}
}
}
But I don't think this is the best practice to solve the problem because the method to get the setupContext is a bit of a hook.
Is it any ideas to solve it?
Stale issue message
Solve it?
I use a wrapper components, which contains a
<slots />
element to allow another component rendered inside. Once the slots element was shown after the setup process, I found the content ofcontext.slots
of wrapper component doesn't mirrored from$scopedSlots
or$slots
.I found another issue about this problem, #911. Here is a test case to explain the situation:
It runs failed due to the undefined of the
slots.default
.