I need to set the index of a v-for to a dynamic v-model, but I don't know how to do that without trigger an error, I have tried this that works but is not elegant and gave me errors in the console:
In my template section:
<div v-for="(ob, index) in $v.especifications.$each.$iter" :key="index" class="row">
<div class="form-group" :class="{ 'form-group--error': $v.$error }">
<label for="number">Número:</label>
<input v-model="ob.numero.$model = parseInt(index)+1" type="number" class="form-control" id="number" aria-describedby="number" disabled>
<div class="alert alert-danger" role="alert" v-if="ob.numero.$dirty && !ob.numero.required">Es requerida una fecha de inicio</div>
</div>
</div>
In my script section:
export default {
data () {
return {
especifications: [{
descripcion: '',
numero: '',
cantidad: ''
}],
}
}
}
Errors:
Module Warning (from ./node_modules/eslint-loader/index.js):
error: 'v-model' directives require the attribute value which is valid as LHS (vue/valid-v-model)
And
error: 'v-model' directives cannot update the iteration variable 'x' itself (vue/valid-v-model)