[英]Passing slots in h() render function in Vue3
I'm a bit confused on how to convert this template to an h() function in Vue 3我对如何在 Vue 3 中将此模板转换为 h() function 有点困惑
<n-tooltip trigger="hover">
<template #trigger>
<n-button> Duck </n-button>
</template>
If it looks like a duck, walks like a duck, and quacks like a duck...it must
be a duck.
</n-tooltip>
I've tried this but I know I'm doing something wrong我试过了,但我知道我做错了什么
return h(NTooltip, { trigger: 'hover' } ,
[h('template' , null , { trigger: () => h(NButton,'Duck') } ),
h('p','If it looks like a duck, walks like a duck, and quacks like a duck...it must be a duck')] )
Any help is really appreciated.非常感谢任何帮助。
h('template')
is not needed for template tags, just return the content inside the object (of the 3 param)h('template')
,只需返回 object 内的内容(3个参数)default:
)default:
p
is not in the template example, and you don't need it in the render function either, just return the textp
不在模板示例中,并且您在渲染 function 中也不需要它,只需返回文本return h(
NTooltip,
{ trigger: 'hover' } ,
{
trigger: () => h(NButton,'Duck'),
default: () => 'If it looks like a duck, walks like a duck, and quacks like a duck...it must be a duck'
}
)
more info at: https://vuejs.org/guide/extras/render-function.html#passing-slots更多信息: https://vuejs.org/guide/extras/render-function.html#passing-slots
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.