0👍
Try this
If you want to pass the index from the loop to Autofill, then you should use the methods.
You cannot pass data to a function from computed.
<div class="inputArea mt-2" v-for="(id, index) in inputs" :key="index">
<div class="row">
<div class="col-md-6 m-1">
<div class="mt-2">Number</div>
<b-form-input type="number" v-model="Number[index]"></b-form-input>
</div>
<div class="row">
<div class="col-md-5 ml-1 mr-1">
<div class="mt-2">Autofill 1</div>
<b-form-input type="text" :value="Autofill(index).autofill1" </b-form-input>
</div>
<div class="col-md-5 ml-1 mr-1">
<div class="mt-2">Autofill 2</div>
<b-form-input type="text" :value="Autofill(index).autofill2" </b-form-input>
</div>
</div>
</div>
</div>
<script>
export default {
//...
methods: {
Autofill(index) {
var returnelement = {};
if (this.json != undefined) {
this.json.forEach(element => {
for (const item of index) {
if (+element.number === +item)
returnelement = element;
}
});
}
return returnelement;
},
},
}
</script>
- [Vuejs]-V-date-picker customize it and have today, last 7 days beside it
- [Vuejs]-Black Images when transforming HTML to Jpeg
Source:stackexchange.com