v-for — renders elements by iterating over an array or object. v-if — conditionally renders elements based on a boolean expression.
v-for:
v-if:
1<template>2 <!-- v-for: iterate over array -->3 <ul>4 <li v-for="item in items" :key="item.id">5 {{ item.name }}6 </li>7 </ul>89 <!-- v-if: conditional -->10 <div v-if="isLoggedIn">Welcome back!</div>11 <div v-else>Please log in.</div>12</template>
Important: