[Vuejs]-How do you increment preface to element using v-for in Vue.JS

0👍

The simple answer is: You don’t

if you want to iterate over an array you can do it like this:

<div v-if="results" v-for="t in results"> 
    <a :href="'/' + t['1. symbol']">{{ t['1. symbol'] }} -- {{ t['2. name'] }}</a>
</div>

and if you really need the index for something you can do it like this:

<div v-if="results" v-for="(t, i) in results"> 
    <a :href="'/' + t['1. symbol']">{{i}}: {{ t['1. symbol'] }} -- {{ t['2. name'] }}</a>
</div>

Live example in Vue playground

Leave a comment