this is my code
<li v-for="(data, index) in datas" :key="data.id" class="nav-item">
<a :href="#" :class="'nav-link '+ { 'active' : index === 0 }" data-toggle="tab">
{{data.name}}
</a>
</li>
but output only showing like this
<a href="#" data-toggle="tab" class="nav-link [object Object]">test</a>
this is my code
<li v-for="(data, index) in datas" :key="data.id" class="nav-item">
<a :href="#" :class="'nav-link '+ { 'active' : index === 0 }" data-toggle="tab">
{{data.name}}
</a>
</li>
but output only showing like this
<a href="#" data-toggle="tab" class="nav-link [object Object]">test</a>
Share
Improve this question
edited Aug 22, 2019 at 19:24
Boussadjra Brahim
1
asked Feb 7, 2019 at 22:26
Job RajanJob Rajan
1951 gold badge6 silver badges14 bronze badges
2 Answers
Reset to default 4You should do it as follows by separating the bound class from the not bound one :
<a :href="#" class="nav-link" :class="{ 'active' : index === 0 }" data-toggle="tab">
{{data.name}}
</a>
You can add static class with dynamic class bindings by taking array of classes instead of concatenating by '+' operator.
<li v-for="(data, index) in datas" :key="data.id" class="nav-item">
<a :href="#" :class="[nav-link,{ 'active' : index === 0 }]" data-toggle="tab">
{{data.name}}
</a>
</li>