<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>V-model</title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
<input type="text" v-model="firstname"> +
<input type="text" v-model="lastname"> =
<input type="text" v-model="fullname">
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
firstname: '',
lastname: '',
fullname: ''
},
methods: {
},
watch:{
firstname:function(newVal, oldVal){
this.fullname = newVal + '----' + this.lastname
},
lastname:function(newVal, oldVal){
this.fullname =this.firstname + '----' + newVal
}
}
});
</script>
</body>
</html>