The following code will produce an empty comment node i.e. <!---->
.
How to produce a non-empty comment node e.g. <!-- Foo -->
using h
?
export default {
render(h) {
return h(null)
},
}
The following code will produce an empty comment node i.e. <!---->
.
How to produce a non-empty comment node e.g. <!-- Foo -->
using h
?
export default {
render(h) {
return h(null)
},
}
It seems Vue 2.6.14 no longer allows doing any of the following, but it's possible in Vue 3.
Option 1:
h(null)
with string as second argumentNote: This generates a runtime warning about using
null
:You could workaround that with
resolveDynamicComponent(null)
instead ofnull
:Option 2:
h(Comment)
with string as second argumentOption 3:
createCommentVNode()
with string as argumentNote:
createCommentVNode
is an internal API, which can be removed/renamed in a future release, so use it with caution.Vue 3 demo