Targeting last item in v-repeat with Vue JS Targeting last item in v-repeat with Vue JS vue.js vue.js

Targeting last item in v-repeat with Vue JS


For Vue 2.0 the code looks slighly different:

<li v-for="(item, index) in items" v-bind:class="{last : index === (items.length-1)}">  <i class="material-icons">{{ icon }}</i>    {{ name }}</li>


You just need to add v-class like this

<li v-repeat="items" v-class="last : $index === (items.length-1)">  <i class="material-icons">{{ icon }}</i>    {{ name }}</li>

where last is the class you want to add