Skip to content

Commit 5a0983e

Browse files
author
wangjiachen
committed
修改Index.html
1 parent b25c18b commit 5a0983e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

index.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<body>
88
<h1 id="name"></h1>
99
<input type="text">
10+
<input type="button" value="改变data内容" onclick="changeInput()">
11+
1012
<script src="observer.js"></script>
1113
<script src="watcher.js"></script>
1214
<script>
@@ -22,14 +24,20 @@ <h1 id="name"></h1>
2224

2325
var ele = document.querySelector('#name');
2426
var input = document.querySelector('input');
25-
27+
2628
var myVue = new myVue({
27-
name: 'hello world'
28-
}, ele, 'name');
29+
name: 'hello world'
30+
}, ele, 'name');
2931

32+
//改变输入框内容
3033
input.oninput = function (e) {
3134
myVue.data.name = e.target.value
3235
}
36+
//改变data内容
37+
function changeInput(){
38+
myVue.data.name = "难凉热血"
39+
40+
}
3341
</script>
3442
</body>
3543
</html>

0 commit comments

Comments
 (0)