티스토리 뷰

v-if를 쓸 때 쓸데없는 html 태그가 렌더되는 것을 원치 않을 때는 <template>를 쓰면 된다! v-if와 함께 쓰면 html가 렌더되지 않는다. 

<template>
  <div class="background">
    <div class="write-modal">
      <h4 class="title">작성하기</h4>
      <template v-if="true"> // template 사용
        <div>TEST</div>
      </template>
      <button class="close-btn" @click="clickHideModalBtn">
        <span
          class="pi pi-times icon"
          style="font-size: 1.2rem; color: #000"
        ></span>
      </button>
    ...
  </div>
</template>

렌더 된 html 태그

 

v-if 없이 사용하면 일반 html template 태그로 인식하는 것 같다.. 🤔

 

728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함