Kevin Hernandez
Kevin Hernandez

Reputation: 1400

Vue V:model create object dynamically

I currently have:

<div id="fields" v-for="(key, field) in ui.account.search_field_url_map" v-bind:key="field.stageName">
   <h2>{{meta.account[field]}}</h2> 
   <input type="text" :v-model="search.field = field" :name="field" placeholder="John">
</div>

This div loads data with v-for this object has a key that I want to be able to use inside of my v-model where data is, inside my data I have:

data(){
    search: {}
}

I want to create objects inside of search based on the data that is being passed through the v-for

Right now if I do

:v-model="search.field = field" I get:

field: "BillingCity"

But I want it to be:

BillingCity: "Whatever input from the form here"

How can I do this?

Upvotes: 0

Views: 2091

Answers (1)

Kevin Hernandez
Kevin Hernandez

Reputation: 1400

Doing:

v-model="search[field]"

did the trick for me

Upvotes: 2

Related Questions