[Vuejs]-How to bind an input to Vue instance after it is initialized?

0๐Ÿ‘

I have tried your code and noticed two things if you wish to bound second input to the model. I would recommend using different v-model, like this:

<div id="app">
    <input type="text" id="text1" v-model="data1">
    <input type="text" id="text2" v-model="data2">
</div>

Also, when you initialise Vue, you should state a second variable like this:

var vm = new Vue({
  el: '#app',
  data: {
      data1: 'some initial text',
      data2: 'some initial text 2'
  }
})

If you do it like this then everything should work fine.

Here is a demo link with source code.

P.S. I hope that I have understood your question correctly and given you a desired answer

๐Ÿ‘คAndrey Seregin

Leave a comment