-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
41 lines (39 loc) · 1.14 KB
/
index.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
41
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MVVM</title>
</head>
<body>
<div id="app">
<div>
<input type="text" v-model="name" placeholder="姓名" />
<input type="text" v-model="age" placeholder="年龄" />
<input type="text" v-model="email" placeholder="邮箱" />
<input type="text" v-model="tel" placeholder="电话号码" />
</div>
<div>
<p>姓名:<span>{{ name }}</span></p>
<p>年龄:<span>{{ age }}</span></p>
<p>邮箱:<span>{{ email }}</span></p>
<p>
<p>电话号码:<span>{{ tel }}</span></p>
</p>
</div>
<button id="btn">改变名字</button>
</div>
<script src="./index.js"></script>
<!-- <script src="./index2.js"></script> -->
<script>
const app = new MVVM('#app', {
name: '',
age: '',
email: '',
tel: ''
})
document.querySelector('#btn').addEventListener('click', function() {
app.setData('name', 'BEN');
})
</script>
</body>
</html>