mardi 8 octobre 2019

vue v-for index undefined in array object

I have code like this

<div class="form-group">
    <div class="alert alert-success" v-if="alert_permission">Izin telah diberikan</div>
        <template v-for="(row, index) in permissions">
            <input
              type="checkbox"
              class="flat-red new-select"
              :key="index"
              :checked="row.name == user_permissions[index].name  ? 'checked' : ''"
              :value="row.name"
              @click="addPermission(row.name)"
            />
            
            <br :key="'row' + index" />
            <br :key="'enter' + index" v-if="(index+1) %3 == 0" />
        </template>
    </div>
</div>

In my case, I want to checked checkbox when row.name is same with data model in array object. but if write like user_permissions[0].name thats work on 1 item only.

How can i use index in that case?




Aucun commentaire:

Enregistrer un commentaire