[Vuejs]-An array item value taken from input's v-model

-2👍

You can use the @change event.

Compare: https://v2.vuejs.org/v2/guide/forms.html

Fiddle: https://jsfiddle.net/mgLrv4kd/1/

new Vue({
  el: '#app',
  data: {
    selected: [],
    otherText: null
  },
  methods: {
    getInput(input) {
      this.selected.push(input);
    }
  }
})
 <input type="text" v-model="otherText" @change="getInput(otherText)">

Leave a comment