9 months ago

How to handle dynamic input filed with one v-model

Posted 9 months ago by uksarkar

I am showing some input fields based on database. And I am trying to set one v-model on it. My code is here

<div class="form" v-for="product in products">
    <div class="title">@{{ product.title }} </div>
    <div class="qnt">
        <input type="number" v-model="form.qnt[]">

// vue data property
data: {
    form: {
        qnt: []

I have loaded two products id(2,3). Now I am getting output like this [ 0:undefined, 1:undefined, 2:"5", 3:"4" ]. How can I get output like this [productId:inputValue].

Please sign in or create an account to participate in this conversation.