[Vuejs]-Vuejs, the v-model derective can bind the json

0👍

Try using this

Html

<div id="editor">
      <input type="text" v-model="user.name"/>
     <input type="text" v-model="user.nickname"/>
    </div>

SCRIPT

new Vue({
  el: '#editor',
  data: {
    user:{
        name:"tom",
        nickname:"tom1"
        }
  }
})

0👍

Sure you can, see the snippet with the prop user.name changed by code and updating the Input text through Two-way data-binding functionality.

new Vue({
    el: '#app',
    data: {
      user:{
          name:"tom",
          nickname:"tom1"
          }
    },
    methods: {
    	onClick() {
      	this.user.name = 'Tomas'
      	console.log(this.user.name)
      }
    }
})
<script src="https://npmcdn.com/vue/dist/vue.js"></script>

<div id="app">
  <div id="editor">
      <input type="text" v-model="user.name"/>
     <input type="text" v-model="user.nickname"/>
    </div>
    <button v-on:click="onClick">Change name by code</button>
</div>

Leave a comment