fix(nuxt): pass attrs and props to client-only components (#5668)

This commit is contained in:
Daniel Roe 2022-06-30 15:08:05 +01:00 committed by GitHub
parent 568fcaedfc
commit fe508f5d20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,14 +21,15 @@ export default defineComponent({
export function createClientOnly (component) {
return defineComponent({
name: 'ClientOnlyWrapper',
setup (props, { attrs, slots }) {
inheritAttrs: false,
setup (_props, { attrs, slots }) {
const mounted = ref(false)
onMounted(() => { mounted.value = true })
return () => {
if (mounted.value) {
return h(component, { props, attrs }, slots)
return h(component, attrs, slots)
}
return h('div')
return h('div', { class: attrs.class, style: attrs.style })
}
}
})