fix(nuxt): add missing imports to <NuxtClientFallback> (#20237)

This commit is contained in:
Daniel Roe 2023-04-12 18:10:18 +01:00 committed by GitHub
parent 22f1f71e3e
commit e5d1d29b1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import { createElementBlock, defineComponent } from 'vue' import { createElementBlock, defineComponent, onMounted, ref } from 'vue'
import { useState } from '../composables/state'
export default defineComponent({ export default defineComponent({
name: 'NuxtClientFallback', name: 'NuxtClientFallback',

View File

@ -1,5 +1,6 @@
import { defineComponent, getCurrentInstance, onErrorCaptured } from 'vue' import { defineComponent, getCurrentInstance, onErrorCaptured, ref } from 'vue'
import { ssrRenderAttrs, ssrRenderSlot, ssrRenderVNode } from 'vue/server-renderer' import { ssrRenderAttrs, ssrRenderSlot, ssrRenderVNode } from 'vue/server-renderer'
import { useState } from '../composables/state'
import { createBuffer } from './utils' import { createBuffer } from './utils'
const NuxtClientFallbackServer = defineComponent({ const NuxtClientFallbackServer = defineComponent({
@ -40,8 +41,8 @@ const NuxtClientFallbackServer = defineComponent({
const defaultSlot = ctx.slots.default?.() const defaultSlot = ctx.slots.default?.()
const ssrVNodes = createBuffer() const ssrVNodes = createBuffer()
for (let i = 0; i < defaultSlot.length; i++) { for (let i = 0; i < (defaultSlot?.length || 0); i++) {
ssrRenderVNode(ssrVNodes.push, defaultSlot[i], vm) ssrRenderVNode(ssrVNodes.push, defaultSlot![i], vm!)
} }
return { ssrFailed, ssrVNodes } return { ssrFailed, ssrVNodes }
@ -52,7 +53,7 @@ const NuxtClientFallbackServer = defineComponent({
return { ssrFailed: true, ssrVNodes: [] } return { ssrFailed: true, ssrVNodes: [] }
} }
}, },
ssrRender (ctx, push, parent) { ssrRender (ctx: any, push: any, parent: any) {
if (ctx.ssrFailed) { if (ctx.ssrFailed) {
const { fallback, placeholder } = ctx.$slots const { fallback, placeholder } = ctx.$slots
if (fallback || placeholder) { if (fallback || placeholder) {