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