You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
714 B
32 lines
714 B
2 years ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<title>4.姓名案例_计算属性简写</title>
|
||
|
<script type="text/javascript" src="../vue.js"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="root">
|
||
|
姓:<input type="text" v-model="firstName"> <br>
|
||
|
名:<input type="text" v-model="lastName"> <br>
|
||
|
姓名: <span>{{fullName}}</span>
|
||
|
</div>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
const vm = new Vue({
|
||
|
el: '#root',
|
||
|
data: {
|
||
|
firstName: "张",
|
||
|
lastName: "三"
|
||
|
},
|
||
|
computed: {
|
||
|
fullName() {
|
||
|
return this.firstName + '-' + this.lastName
|
||
|
}
|
||
|
}
|
||
|
|
||
|
})
|
||
|
console.log(vm)
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|