Answer the question
In order to leave comments, you need to log in
How to display input correctly in a loop?
Hello!
Such a problem, there is a v-for loop, it displays the input at each iteration, I need to bind to the v-model input, but if I do this, then when I write to one input, the same value is displayed in the rest of the others, how to fix it ?
Here is the code
<div class="row departament align-items-center p-2 mt-3">
<div class="departament-head col-lg-6">
{{ departament.departament_name }}
</div>
<div class="departament-head_btn col-lg-6 text-right">
<button @click="editDepartament(departament)" type="button" class="btn btn-primary">Редактировать</button>
<button @click="deleteDepartament(departament.id)" type="button" class="btn btn-danger">Удалить</button>
</div>
<departament-worker :departamentId="departament.id"></departament-worker>
<div class="input-group mt-3">
<input type="text" class="form-control" v-model="worker.worker_name" :key="departament.id" placeholder="Имя сотрудника" aria-label="Имя сотрудника" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-outline-secondary btn-primary text-light" type="button">Сохранить</button>
</div>
</div>
</div>
data() {
return {
departaments: [],
work: '',
departament: {
id: '',
departament_name: ''
},
worker: {
worker_name: ''
},
loading: true
}
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question