Compiler-Informed VDOM <template> <!-- 1. 完全に静的な要素 --> <p class="static">これ 静的なテキストです。</p> <!-- 2. テキストコンテンツだけが動的な要素 --> <p>{{ message }}</p> <!-- 3. class属性だけが動的な要素 --> <div :class="{ active: isActive }">クラスが動的です。</div> <!-- 4. class/style以外 属性が動的な要素 --> <button :id="dynamicId" :disabled="isDisabled">IDとdisabledが 動的</button> <!-- 5. 複数 動的バインディングを持つ要素 --> <input :id="dynamicId" :class="{ active: isActive }" :value="message"> </template> <script> import { ref } from 'vue' export default { setup() { const message = ref('こんにち '); const isActive = ref(true); const dynamicId = ref('my-id'); const isDisabled = ref(false); return { message, isActive, dynamicId, isDisabled }; } } </script> import { openBlock, createElementBlock, createElementVNode, toDisplayString, normalizeClass } from "vue" // 1. 静的な要素 Static Hoistingされる (Patch Flag: -1) const _hoisted_1 = /*#__PURE__*/createElementVNode("p", { class: "static" }, "これ 静的なテキストです。", -1 /* HOISTED */) export function render(_ctx, _cache, $props, $setup, $data, $options) { return (openBlock(), createElementBlock("div", null, [ _hoisted_1, // 2. テキストだけが動的 -> Patch Flag: 1 (TEXT) createElementVNode("p", null, toDisplayString(_ctx.message), 1 /* TEXT */), // 3. classだけが動的 -> Patch Flag: 2 (CLASS) createElementVNode("div", { class: normalizeClass({ active: _ctx.isActive }) }, "クラスが動的です。", 2 /* CLASS */), // 4. class/style以外 属性が動的 -> Patch Flag: 8 (PROPS) // 第5引数で、動的な属性名を具体的に指定 ["id", "disabled"] createElementVNode("button", { id: _ctx.dynamicId, disabled: _ctx.isDisabled }, "IDとdisabledが動的", 8 /* PROPS */, ["id", "disabled"]), // 5. 複数 動的バインディング -> Patch Flag ビット演算で結合される // 16 (FULL_PROPS) が使われることが多い createElementVNode("input", { id: _ctx.dynamicId, class: normalizeClass({ active: _ctx.isActive }), value: _ctx.message }, null, 16 /* FULL_PROPS */) ])) } コンポーネント ソースコード コンパイル後 コード