-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest3.html
41 lines (39 loc) · 953 Bytes
/
test3.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>test3</title>
</head>
<body>
<script src="./js/observer.js"></script>
<script src="./js/watcher.js"></script>
<div id="app">{{ word }}</div>
<script>
/* eslint-disable no-new */
/* eslint-disable no-undef */
function mvue(options, prop) {
this.$options = options
this.$data = options.data
this.$prop = prop
this.$el = document.querySelector(options.el)
this.init()
}
mvue.prototype.init = function() {
observer(this.$data)
this.$el.textContent = this.$data[this.$prop]
new Watcher(this, this.$prop, value => {
this.$el.textContent = value
})
}
const vm = new mvue(
{
el: '#app',
data: {
word: 'hello world'
}
},
'word'
)
</script>
</body>
</html>