I'm trying to understand the use case of <template>
and it's functions. Having referenced the docs, I'm still left fairly confused.
Considering the following code in any.vue file:
<template>
<div class="top-right links">
<!-- Why use <template> here instead of a div, for example? -->
<template v-if="authenticated">
<router-link :to="{ name: 'home' }">
{{ $t('home') }}
</router-link>
</template>
<template v-else>
<router-link :to="{ name: 'login' }">
{{ $t('login') }}
</router-link>
</template>
</div>
</template>
Why would we use <template>
instead of just a simple <div>
, and how is using <template>
different than say, using a <custom-component>
?
<template v-if="authenticated">
inside a template when you can use a<div v-if="authenticated>"
... – Beene