watch 监听不生效,还报错
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="js/vue.js"> </script>
</head>
<body>
<div id="root">
<input placeholder="姓氏" v-model="firstname" />
<input placeholder="名字" v-model="lastname" />
{{fullName}}
{{count}}
</div>
<script>
new Vue({
el:"#root",
data:{
firstname:'',
lastname:'',
count:0
},
computed:{
fullName:function(){
//if(this.firstname!=''&&this.lastname!=''){
return this.firstname+'·'+this.lastname
// }
},
watch:{
firstname:function(){
this.count= count+1
return count
},
lastname:function(){
this.count= count+1
return count
}
}
}
})
</script>
</body>
</html>