<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
姓:<input v-model:value="firstName">
名:<input v-model:value="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:{
firstName: function () {
this,count++
}
}
})
</script>
</body>
</html>