</ul>
<router-view class="view" v-slot="{ Component, props }">
<transition name="fade" mode="out-in">
- <component :is="Component" v-bind="props"></component>
+ <component v-if="Component" :is="Component" v-bind="props"></component>
</transition>
</router-view>
</div>
)
const propsData = computed(() => {
- // propsData only gets called if ViewComponent.value exists and it depends on matchedRoute.value
+ // propsData only gets called if ViewComponent.value exists and it depends
+ // on matchedRoute.value
const { props } = matchedRoute.value!
if (!props) return {}
if (props === true) return route.value.params
let Component = ViewComponent.value
const componentProps: Parameters<typeof h>[1] = {
+ // only compute props if there is a matched record
...(Component && propsData.value),
...attrs,
onVnodeMounted,
ref: viewRef,
}
+ // NOTE: we could also not render if there is no route match
const children =
- Component &&
- slots.default &&
- slots.default({ Component, props: componentProps })
+ slots.default && slots.default({ Component, props: componentProps })
return children
? children