-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
73 lines (71 loc) · 1.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue</title>
<script src="vue.js"></script>
</head>
<body>
<div id="demo">
<input v-model='name' />
<p v-text='name'></p>
<!-- xss安全问题:就是很容易让别人插入标签script -->
{{{html}}}
<p v-html='html'></p>
<button v-on:click='Click()'>ok</button>
<input type="text" v-on:focus="Click()" v-model='input'>
<div>{{input}}</div>
<button @click='BB()'>点击</button>
</div>
<div id="demo2">
<button @click='BB()'>点击</button>
</div>
</body>
<script>
//view公用方法
var BB = function() {
console.log(this.name);
}
//创建model
var demo = new Vue({
//element的缩写
el:'#demo',
data:{
name:'这是第一个vue:ggithub',
},
methods:{
Click:function() {
console.log('hello world!'+this.name);
//闭包函数中的this指的是window
//(funciton(){
// console.log(this);
//})()
},
ggithub:function() {
console.log('hello!');
},
BB,
},
ready:function() {
this.BB();
}
})
demo.Click();
demo.ggithub();
//设置数据
// demo.name = 'tt';
// demo.$data.name = 'tt';
demo.$set('name','tt');
//获取name的value值
demo.$get('name');
new Vue({
el:"#demo2",
data:{
name:'这是第二个',
},
methods:{
BB,
}
})
</script>
</html>