[Vuejs]-Put dynamic data in v-model

0👍

See this fiddle for a working example. v-model doesn’t need the : in front.

new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue.js!',
    items: [{
        key: "test one"
    },
    {
        key: "test two"
    },
    {
        key: "test three"
    }]
  }
})

and the dom:

<script src="https://unpkg.com/vue"></script>

<div id="app">
  <p>{{ message }}</p>
  <div v-for="(item, index) in items" :key="index">
   <input v-model="item.key" />
  </div>
</div>

Docs link: Vue form bindings

Leave a comment