There is a case where we used:
<template>
<div id="app">
<button @click="fetch">Fetch numbers</button>
<div v-if="!getNumbers.length">Waiting for numbers...</div>
<div v-if="getNumbers.length">
<div v-for="number in getNumbers" :key="number.id">
<h5>{{ number.owner }}</h5>
<p>{{ number.phone }}</p>
</div>
</div>
</div>
</template>
Is it a good practice? If not then how can be this improved?
v-forandv-iftogether (which you're not doing anyway). The only optimization I would suggest is that you use<template>for the outer v-if, since you're using the div as simply a placeholder element.v-elseinstead, but that shouldn't change the computational effort behind it.<template v-if="getNumbers.length"> ... </template>, so you don't unnecessary produce a dummy<div>element. Or even better, just<template v-else>