Go back to Examples

Conditional rendering

CMS - Intermediate

Conditional rendering allows you to render content only if a condition is met, such as if an item has an image then render the image element.

                <template v-for="post in posts">
    <template v-if="post.image">
        <img v-bind:src="post.image" />
    </template>
</template>