0👍
You can use v-for to loop through a variable in vue.js and use index to check for the first element. Use v-bind:class to apply a class dynamically. The correct solution for doing this should be:
<ul class="nav nav-tabs nav-cat">
<li v-for="(country, index) as {$countries}" role="presentation" :class="{index == 0 : 'active'}"><a href="javascript:;" data-toggle="tab" @click="$refs.player.getPlayer(country.id )">{{ ucfirst(country.name) }}</a>
</li>
</ul>
- [Vuejs]-Laravel VueJS – Cannot find element: #navigation
- [Vuejs]-What is the best practice to develop the cross-platform components with Vue.js 2.0?
-5👍
Using JQuery:
$("#ID").addClass("active");
Using Javascript:
document.getElementById("ID").className += " active";
- [Vuejs]-Where can I see the output if I put a console.log in vue.config.js?
- [Vuejs]-Vue conditional css does not always trigger
Source:stackexchange.com