Question about the recommended way to achieve KeepAlive-like page persistence in vike-vue
#3433
ContextI am trying to preserve routed page instances across client-side navigations in a My first intuition was to use Vue's <template>
<AppLayout>
<KeepAlive>
<slot />
</KeepAlive>
</AppLayout>
</template>In practice, what I observe is:
Minimal observationFrom reading the runtime, it looks like this may be related to how Source path:
Current logic: const entryComponentRef = shallowRef(pageContext.config[entryComponentName])
const layoutRef = shallowRef(pageContext.config.Layout || [])
const EntryComponent = () => h(entryComponentRef.value)
RootComponent = () => {
let RootComp = EntryComponent
layoutRef.value.forEach((layout) => {
const Comp = RootComp
RootComp = () => h(layout, null, Comp)
})
return RootComp()
}Because the page is wrapped by the Vike runtime before being exposed through Local experimentI also tried a local runtime experiment that wraps the routed Source path:
const EntryComponent = () =>
h(KeepAlive, null, {
default: () => h(entryComponentRef.value)
})With this change:
Main questionIf the goal is to achieve More specifically:
Why I am askingI found a local runtime patch that changes the behavior, but I do not want to assume that patching the runtime is the right direction. Before taking any implementation approach, I would like to understand what the maintainers consider the correct or recommended solution for achieving |
Replies: 1 comment 3 replies
|
https://vike.dev/vue-setting released in |
https://vike.dev/vue-setting released in
vike-vue@0.9.13.