i'm trying to loop through array of objects to make a list of input field, everything works fine except v-model, it just appears in the text-field but nothing changed, i've seen a lot of similar questions here but none of the answers worked
my root component:
<template>
<div class="container">
<add-product :inputs="inputs"></add-product>>
</div>
</template>
<script>
export default {
data(){
return{
inputs: [
{id: '1', label: 'name', type: 'text', model:'name'},
{id: '2', label: 'description', type: 'text', model: 'desc'},
{id: '3', label: 'price', type: 'text', model: 'price'},
{id: '4', label: 'size', type: 'text', model: 'size'},
{id: '5', label: 'stock', type: 'text', model: 'stock'},
]
}
},
components: {
addProduct: AddProduct
}
}
Nested component:
<template>
<transition name="fade">
<div class="add-box">
<div class="input--form" v-for="(input, index) in inputs" :key="index">
<label >{{ input.label }}: </label>
<input :type="input.type" v-model="input.model">
</div>
</div>
</transition>
</template>
<script>
export default {
props: {
inputs: Array
},
data(){
return{
name: '',
desc: '',
price: '',
size: '',
stock: ''
}
},
</script>