mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): bind createClientOnly
render function to ctx (#22289)
This commit is contained in:
parent
7046930a67
commit
2e6c4519cf
@ -34,7 +34,7 @@ export function createClientOnly<T extends ComponentOptions> (component: T) {
|
||||
// override the component render (non script setup component)
|
||||
clone.render = (ctx: any, ...args: any[]) => {
|
||||
if (ctx.mounted$) {
|
||||
const res = component.render!(ctx, ...args)
|
||||
const res = component.render?.bind(ctx)(ctx, ...args)
|
||||
return (res.children === null || typeof res.children === 'string')
|
||||
? createElementVNode(res.type, res.props, res.children, res.patchFlag, res.dynamicProps, res.shapeFlag)
|
||||
: h(res)
|
||||
|
11
test/fixtures/basic/components/client/Binding.client.ts
vendored
Normal file
11
test/fixtures/basic/components/client/Binding.client.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
export default defineComponent({
|
||||
name: 'Foo',
|
||||
methods: {
|
||||
getMessage () {
|
||||
return 'Hello world'
|
||||
}
|
||||
},
|
||||
render () {
|
||||
return h('div', {}, this.getMessage())
|
||||
}
|
||||
})
|
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<ClientBinding />
|
||||
<ClientScript ref="clientScript" class="client-only-script" foo="bar" />
|
||||
<ClientSetupScript
|
||||
ref="clientSetupScript"
|
||||
|
Loading…
Reference in New Issue
Block a user