2.计算属性与监听器
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>计算属性与监听器</title> <script src="./vue.js" type="text/javascript" charset="utf-8"></script> </head> <body> <div id="root"> 姓:<input v-model="firstName" /> 名:<input v-model="lastName" /> <div id=""> {{fullName}} </div> <div id=""> {{count}} </div> </div> <script type="text/javascript"> new Vue({ el:"#root", data:{ firstName:'', lastName:'', count: 0 }, computed:{ //计算属性 fullName:function(){ return this.firstName + ' ' + this.lastName } }, watch:{ //侦听器 // firstName:function(){ // this.count++ // }, // lastName:function(){ // this.count++