Closed1
【Vue.js】template

- DOMに出力されない仮想なラッパー要素
- 出力されないためコード上の構造化のために利用でき、余計なDOMを出力しなくて済む
- v-ifやv-forなどで要素のグルーピングによく使われる
<template>
<template v-if="flg">
<h1>Title</h1>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
</template>
<ul>
<template v-for="item in [1, 2, 3]">
<li>{{ item }}</li>
</template>
</ul>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const flg = ref(false);
</script>
template要素はレンダリングされない
参考
このスクラップは6ヶ月前にクローズされました