河北小王爷99
2019-03-03 09:54
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>计算属性与侦听器</title>
<script src="vue.js"></script>
</head>
<body>
<div id="root">
姓:<input type="text" v-model="firstName" />
名:<input type="text" v-model="lastName" />
<div>{{fullName}}</div>
<div>{{count}}</div>
</div>
<script>
new Vue({
el:"#root",
data:{
firstName: "",
lastName: "",
count: 0
},
computed:{ /**计算属性*/
fullName: function(){
return this.firstName + " " + this.lastName
}
},
watch: {
firsName: function(){
this.count ++
},
lastName: function(){
this.count ++
}
}
})
</script>
</body>
</html>
不好意思 侦听器事件里 firstName 我漏写了一个t
vue2.5入门
146742 学习 · 657 问题
相似问题