1

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)
  },
}
Wenfang Du
  • 5,689
  • 6
  • 40
  • 66

1 Answers1

1

Option 1: h(null) with string as second argument

export default {
  render(h) {
    return h(null, 'This is a comment')  // <!--This is a comment-->
  },
}

Option 2: h(Comment) with string as second argument

import { h, Comment } from 'vue' // Vue 3

export default {
  render() {
    return h(Comment, 'This is a comment')  // <!--This is a comment-->
  },
}

Option 3: createCommentVNode() with string as argument

import { createCommentVNode } from 'vue' // Vue 3

export default {
  render() {
    return createCommentVNode('This is a comment')  // <!--This is a comment-->
  },
}
tony19
  • 99,316
  • 15
  • 147
  • 208