-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
106 lines (101 loc) · 2.63 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>VM4IE8</title>
</head>
<body>
<div id="app">
<div v-if="ifShow">Just input 'vm.ifShow=false' in console</div>
<div v-else>
<div>{{text}}</div>
<div v-text="text"></div>
<div v-html="html"></div>
<input type="text" v-model="model">
<span>{{model}}</span>
<div class="none" :class="class">
<span>I have a className of </span>
<span>{{class}}</span>
</div>
<div :style="cssString">I have a bule color.</div>
<div v-show="show" @click="handleShowClick">Click me!</div>
<div>
<span>{{say.hello}}</span>
<span>{{message}}</span>
</div>
<div :data-message="message">I have a attribute of data-message</div>
<div @click="handleComputedClick">
<span>I am a computed value:</span>{{hello}}
</div>
<ul>
<li v-for="item in list" :style="cssString">
<ul>
<li v-for="i in item">{{i}}</li>
</ul>
</li>
</ul>
</div>
</div>
<script src="./src/es5-shim.js"></script>
<script src="./src/es5-sham.js"></script>
<script src="./src/observer.js"></script>
<script src="./src/batcher.js"></script>
<script src="./src/watcher.js"></script>
<script src="./src/directive.js"></script>
<script src="./src/compile.js"></script>
<script src="./src/vm.js"></script>
<script>
var vm = new VM({
el: '#app',
data: {
text: "I am some text!",
html: "<span style='color:red'>red html</span>",
model: "value",
'class': 'abc',
cssString: "color: blue",
bind: "bind",
show: true,
say: {
hello: "hello"
},
message: "everyone",
ifShow: true,
list: [
{
name: 'a',
age: 1
},
{
name: 'b',
age: 2
}
]
},
computed: {
hello: {
get: function() {
return this.say.hello + ' ' + this.message
},
set: function(val) {
val = val.split(' ')
this.say.hello = val[0]
this.say.message = val[1]
}
}
},
methods: {
handleShowClick: function (e) {
this.show = false
},
handleComputedClick: function() {
this.say.hello = 'hi'
}
}
})
vm.$watch('say.hello', function (val, oldVal) {
console.log('say.hello has Changed: the value is now ' + val + ', and old value is ' + oldVal)
this.message = 'You changed'
})
</script>
</body>
</html>