-
Notifications
You must be signed in to change notification settings - Fork 303
/
48.名称案例-方式1.html
40 lines (38 loc) · 1.2 KB
/
48.名称案例-方式1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="./lib/vue.js"></script>
</head>
<body>
<div id="app">
<!--1 我们要监听到文本框数据的改变, 这样才知道什么时候去拼接出一个fullName-->
<!--2 如何监听到文本框数据的改变 keyup事件-->
<!---->
<input type="text" v-model="firstName" @keyup='getFullName'> +
<input type="text" v-model="lastName" @keyup='getLastName'> =
<input type="text" v-model="fullName">
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
firstName: '',
lastName: '',
fullName: ' ',
},
methods: {
getFullName(){
this.fullName = this.firstName + ' ' + this.lastName
},
getLastName(){
this.fullName = this.firstName + ' ' + this.lastName
}
},
})
</script>
</body>
</html>