fix: use component html string inside payload

This commit is contained in:
Yasser Lahbibi 2024-10-20 13:22:21 +02:00 committed by GitHub
parent 49242b2500
commit 200bf3589a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -126,11 +126,11 @@ export default defineComponent({
} }
} }
const ssrHTML = ref<string>('')
if (import.meta.client && instance.vnode?.el) {
ssrHTML.value = getFragmentHTML(instance.vnode.el, true)?.join('') || ''
const key = `${props.name}_${hashId.value}` const key = `${props.name}_${hashId.value}`
const ssrHTML = ref<string>(nuxtApp.payload.data[key]?.html || '')
if (import.meta.client && instance.vnode?.el && !ssrHTML.value) {
ssrHTML.value = getFragmentHTML(instance.vnode.el, true)?.join('') || ''
nuxtApp.payload.data[key] ||= {} nuxtApp.payload.data[key] ||= {}
nuxtApp.payload.data[key].html = ssrHTML.value nuxtApp.payload.data[key].html = ssrHTML.value
} }