Both h
and createVNode
are exposed from vue
.
The documentation on this page seems to imply that they are interchangeable:
The h() function is a utility to create VNodes. It could perhaps more accurately be named createVNode().
However, replacing h
with createVNode
will result in an error being thrown:
<script lang="ts">
import { createVNode, defineComponent, h } from 'vue'
export default defineComponent({
setup() {
// This works fine
return () => h('strong', 'Foo')
// This throws an error
return () => createVNode('strong', 'Foo')
},
})
</script>