P
P
Pavel Kravchenko2018-04-22 14:44:27
JavaScript
Pavel Kravchenko, 2018-04-22 14:44:27

Vue, applying styles to one of several identical elements?

<div v-for="(Etask) in Etasks" :key="Etask.id" class="card-action">
             <div class="card ">
                <div v-bind:class="classcomplite" class="card-content">
                <div class="row">
                  <div class="col s11 m11 l11">
                    <p><h6 v-bind:class="classtext">Name Task: {{ Etask.title }}</h6></p>
                  </div>
                  <div class="col s1 m1 l1">
                    <a href="#" v-bind:class="classcomplite" class="btn-floating red" v-on:click="taskcomplite(Etask.id)"><i class="material-icons">done</i></a>
                  </div>
                </div>
           </div>
     </div>
 </div>

As you can see, several elements with the same styles are rendered, you need to change the styles of only one element, where to set the condition? condition match id with the entity.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2018-04-22
@Krokor

Get the style through the method to which you will pass the Id by which to determine which style to return. Well, or directly in the attribute write

<div v-bind:class="{ 'класс_для_определенного': id === 10, 'класс_для_всех': true }></div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question