CrazyWu
CrazyWu

Reputation: 687

vue.js v-model with array

i have a dynamic number of fields on the page and trying to bind an array to control changes on the page, but got stuck with v-model

Here is how i'm building a page (minimal example to reproduce):

<b-form-group v-for="(element, i) in banners" :key="i"  :label="'Banner ' + (i+1)">
  <input
    type="text" class="form-control"
    :v-model="element.name"
    :name="'bannername[' + i + ']'">
  <img :src="element.image" class="banner-preview">
</b-form-group>

This way i'm getting proper src for the img, but input is empty all the time. (checked the data by changing v-model to value, everything is fine, but i need to bind it here)

Upvotes: 3

Views: 3190

Answers (1)

Alberto Rivera
Alberto Rivera

Reputation: 3752

Use v-model instead of :v-model

Upvotes: 2

Related Questions