如何使用渲染函数 h 来实现下面的模板? #6886
Unanswered
evemike
asked this question in
Help/Questions
Replies: 2 comments 7 replies
-
可以在文档这里找到,如何使用h函数: 关于上面这个模板写成h函数,下面有个例子: <script>
import { h } from 'vue'
import MyComponent from './MyComponent.vue'
import Foo from './Foo.vue'
import Bar from './Bar.vue'
export default {
render() {
return h(
MyComponent,
{ name: 'testRenderSlot' },
{
default: () => h('div', 'default slot'),
foo: () => h(Foo, { id: 'foo' }, () => 'foo slot'),
bar: () => h(Bar, { id: 'bar' }, () => 'bar slot')
}
)
}
}
</script> 既然手写render函数了,极力推荐jsx或者tsx写模板,比用h函数方便许多😉。 |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
// 备注
我在官网并没有找到答案,只能来这里提问了。目前我采用的实现方法是用 createVNode
Beta Was this translation helpful? Give feedback.
All reactions