var vm=new Vue({
el:"#demo",
data:{
firstName:'Foo',
lastName:'Bar',
},
computed:{
fullName:function(){
return this.firstName+' '+this.lastName
}
}
// watch:{
// firstName:function(val){
// this.fullName=val+' '+this.lastName
// },
// lastName:function(val){
// this.fullName=this.firstName+' '+val
// }
// }
})
var vm = new Vue({
el: '#demo',
data: {
firstName: 'Foo',
lastName: 'Bar'
},
computed: {
fullName: function () {
return this.firstName + ' ' + this.lastName
}
}
})
<div id='demo'>
{{ fullName }}
</div>