how to use render function to return router-view-slot? #2152
-
|
I want use render function to achieve the same effect. my code is the resule is blank page thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Here's an example: In that example, I'm importing In general, h(RouterView, null, ({ Component }) => Component)If you wanted to write that out in full it might be something like this: h(RouterView, null, {
default({ Component }) {
return Component ? h(Component) : null
}
})The code above also needs to take account of the initial value of |
Beta Was this translation helpful? Give feedback.
-
|
thanks for your help. |
Beta Was this translation helpful? Give feedback.
Here's an example:
In that example, I'm importing
RouterViewdirectly, rather than usingresolveComponent, but either way should work.In general,
<component :is="foo">becomesh(foo). But in the specific case ofRouterView, theComponentslot prop is already a VNode, so the extrah()call can be skipped:If you wanted to write that out in full it might be something like this:
The code above also needs to take account of the initial value of
Componentbeingundefined.