SOURCE

console 命令行工具 X clear

                    
>
console
var vm=new Vue({
  el:'#demo',
  data:{
    firstName:'Foo',
    lastName:"Bar"
    // fullName:"Foo Bae"
  },
  // watch:{
  //   firstName:function(val){
  //     this.fullName=val+''+this.lastName
  //   },
  //   lastName:function(val){
  // this.fullName=this.firstName+''+val
  //   }
  // }
  computed:{
    // 下面是定义getter函数
    fullName:function(){
      return this.firstName+' '+this.lastName
    }
  }
})
<div id="demo">
  {{fullName}}
</div>