fix: fix on page change

This commit is contained in:
Julien Huang 2024-06-13 23:39:16 +02:00
parent c62776b2e4
commit 211900eb31

View File

@ -67,21 +67,22 @@ export default defineComponent({
type: String, type: String,
default: () => undefined, default: () => undefined,
}, },
dangerouslyLoadClientComponents: {
type: Boolean,
default: false,
},
/** /**
* use the NuxtIslandResponse which has been cached if available * use the NuxtIslandResponse which has been cached if available
* @default true * @default true
*/ */
useCache: { useCache: {
type: Boolean, type: Boolean,
default: true default: true,
},
dangerouslyLoadClientComponents: {
type: Boolean,
default: false,
}, },
}, },
emits: ['error'], emits: ['error'],
async setup (props, { slots, expose, emit }) { async setup (props, { slots, expose, emit }) {
console.log(props.useCache)
let canTeleport = import.meta.server let canTeleport = import.meta.server
const teleportKey = ref(0) const teleportKey = ref(0)
const key = ref(0) const key = ref(0)
@ -194,9 +195,7 @@ export default defineComponent({
appendResponseHeader(event!, 'x-nitro-prerender', hints) appendResponseHeader(event!, 'x-nitro-prerender', hints)
} }
} }
if (import.meta.client) {
setPayload(key, result) setPayload(key, result)
}
return result return result
} }
@ -251,9 +250,9 @@ export default defineComponent({
} }
if (import.meta.client && !instance.vnode.el && props.lazy) { if (import.meta.client && !instance.vnode.el && props.lazy) {
fetchComponent() fetchComponent(!instance.vnode.el && !props.useCache)
} else if (import.meta.server || !instance.vnode.el || !nuxtApp.payload.serverRendered) { } else if (import.meta.server || !instance.vnode.el || !nuxtApp.payload.serverRendered) {
await fetchComponent() await fetchComponent(!instance.vnode.el && !props.useCache)
} else if (selectiveClient && canLoadClientComponent.value) { } else if (selectiveClient && canLoadClientComponent.value) {
await loadComponents(props.source, payloads.components) await loadComponents(props.source, payloads.components)
} }