I would like to bind v-model to an array of values
So i have
paymenttypes:[
{label:'cheque', value:1},
{label:'two', value:2}
]
pays:[],
created(){
this.paymentmethods.forEach((value) => {
this.pays.push({id:value.value, ref: '' , val: 0 })
});
}
now on the template
<div class="row saleTotal" v-for="(key, extrafieldsDetails) in paymentmethods">
<div class="col-sm-4">
<h5>{{extrafieldsDetails.label}}</h5>
</div>
<div class="col-sm-4">
<input type="number" min="0" class="text-right form-control" v-model="pays[key].ref">
</div>
</div>
But am getting an error
cannot read property 'ref' of undefined
What could be wrong? as the pays array has a object with a key of ref. Where am i going wrong?