How to use the createCommentVNode function from vue

Find comprehensive JavaScript vue.createCommentVNode code examples handpicked from public code repositorys.

vue.createCommentVNode is a function provided by the Vue.js framework that creates a virtual node representing a comment in the Vue.js component tree.

165
166
167
168
169
170
171
172
173
174
(_ctx.type || _ctx.iconClass)
  ? (vue.openBlock(), vue.createBlock("i", {
      key: 0,
      class: [_ctx.typeClass, _ctx.iconClass]
    }, null, 2 /* CLASS */))
  : vue.createCommentVNode("v-if", true),
vue.renderSlot(_ctx.$slots, "default", {}, () => [
  (!_ctx.dangerouslyUseHTMLString)
    ? (vue.openBlock(), vue.createBlock("p", _hoisted_1, vue.toDisplayString(_ctx.message), 1 /* TEXT */))
    : (vue.openBlock(), vue.createBlock(vue.Fragment, { key: 1 }, [
fork icon1
star icon2
watch icon1

+ 7 other calls in file

155
156
157
158
159
160
161
162
163
164
    _ctx.isSimple ? 'is-simple' : `is-${_ctx.parent.props.direction}`,
    _ctx.isLast && !_ctx.space && !_ctx.isCenter && 'is-flex',
    _ctx.isCenter && !_ctx.isVertical && !_ctx.isSimple && 'is-center'
  ]
}, [
  vue.createCommentVNode(" icon & line "),
  vue.createVNode("div", {
    class: ['el-step__head', `is-${_ctx.currentStatus}`]
  }, [
    vue.createVNode("div", _hoisted_1, [
fork icon1
star icon2
watch icon1

+ 7 other calls in file

How does vue.createCommentVNode work?

vue.createCommentVNode is a function provided by Vue.js that creates a virtual DOM node representing an HTML comment. The function takes a single argument, the text content of the comment, and returns a virtual node object that can be used with Vue's render functions.

201
202
203
204
205
206
207
208
209
210
        default: _vue.withCtx(() => [!!item.meta.icon ? (_vue.openBlock(), _vue.createBlock("i", {
          key: 0,
          class: [item.meta.icon, "anticon"]
        }, null, 2)) : _vue.createCommentVNode("v-if", true), _vue.createVNode("span", null, _vue.toDisplayString(item.meta.title), 1)]),
        _: 2
      }, 1032, ["onClick"])) : _vue.createCommentVNode("v-if", true)], 64);
    }), 128))]),
    _: 1
  }, 8, ["openKeys", "selectedKeys"])])], 64);
}
fork icon1
star icon1
watch icon4

+ 19 other calls in file

194
195
196
197
198
199
200
201
202
203
    }, {
      default: vue.withCtx(() => [vue.createTextVNode(vue.toDisplayString(route.breadcrumbName), 1)]),
      _: 2
    }, 1032, ["to"])]),
    _: 1
  }, 8, ["routes"])) : vue.createCommentVNode("v-if", true)]),
  default: vue.withCtx(() => [_ctx.pageDesc ? (vue.openBlock(), vue.createBlock("p", _hoisted_2, vue.toDisplayString(_ctx.pageDesc), 1)) : vue.createCommentVNode("v-if", true), vue.renderSlot(_ctx.$slots, "header")]),
  _: 3
}, 8, ["title"])])) : vue.createCommentVNode("v-if", true), vue.createVNode("div", _hoisted_3, [_ctx.layoutType === "card" ? (vue.openBlock(), vue.createBlock(_component_a_card, {
  key: 0
fork icon1
star icon1
watch icon4

+ 3 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { createCommentVNode } from "vue";

const template = `

${createCommentVNode(" This is another comment ")}

`;

const App = {
  template,
};

// Mount the app
const app = Vue.createApp(App);
const vm = app.mount("#app");

In this example, vue.createCommentVNode is used to create two comment vnodes inside a div element. One comment is created with the template syntax ( ), while the other is created using the vue.createCommentVNode function directly. Both comments will be rendered in the resulting HTML.

77
78
79
80
81
82
83
84
85
86
87
const _hoisted_2$1 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/vue.createElementVNode("path", { d: "M470.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L192 338.7 425.4 105.4c12.5-12.5 32.8-12.5 45.3 0z" }, null, -1 /* HOISTED */));
const _hoisted_3$1 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/vue.createElementVNode("path", { d: "M310.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L160 210.7 54.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L114.7 256 9.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 301.3 265.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L205.3 256 310.6 150.6z" }, null, -1 /* HOISTED */));


function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return (vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
    vue.createCommentVNode(" Copy Icon "),
    ($props.icon === 'copy')
      ? (vue.openBlock(), vue.createElementBlock("svg", vue.mergeProps({ key: 0 }, _ctx.$attrs, {
          viewBox: "0 0 512 512",
          xmlns: "http://www.w3.org/2000/svg"
fork icon0
star icon1
watch icon1

+ 13 other calls in file

1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
  ? (vue.openBlock(), vue.createElementBlock("i", vue.mergeProps({
      key: 2,
      class: ['p-dropdown-clear-icon', $props.clearIcon],
      onClick: _cache[7] || (_cache[7] = (...args) => ($options.onClearClick && $options.onClearClick(...args)))
    }, $props.clearIconProps), null, 16))
  : vue.createCommentVNode("", true),
vue.createElementVNode("div", _hoisted_4, [
  vue.renderSlot(_ctx.$slots, "indicator", {}, () => [
    vue.createElementVNode("span", {
      class: vue.normalizeClass($options.dropdownIconClass),
fork icon1
star icon0
watch icon0

+ 124 other calls in file

2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
              ], 42, _hoisted_26)), [
                [_directive_ripple]
              ])
            }), 128))
          ]))
        : vue.createCommentVNode("", true)
    ], 64))
  : vue.createCommentVNode("", true),
(($props.showTime || $props.timeOnly) && $data.currentView === 'date')
  ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_28, [
fork icon1
star icon0
watch icon0

+ 549 other calls in file