-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
119 lines (109 loc) · 2.82 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
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<style>
.bg{
background-color: red;
}
</style>
<body>
<div id="box">
<button v-on:click="run()">test</button>
<a href="h" v-on:click.prevent="show">test</a>
{{msg}}
<p @click="show">test @click</p>
<p v-if="test.length ==4">{{test}}</p>
<p v-else>No</p>
{{b}}
<p :class="{bg:true}">test background</p>
<p :class="vue_bg">test background</p>
<button v-on:click="runs()">testURL</button>
<button v-on:click="post()">testPOST</button>
<input type="text" @keyup="testb" v-model="str">
<ul>
<li v-for="item in arr">{{item}}</li>
</ul>
</div>
<script src="vue.js"></script>
<script src="vue-resource.js"></script>
<script>
new Vue({
el:"#box",
data:{
msg:"this is data",
test:"haha",
h:"a.html",
vue_bg:"bg",
str:"",
arr:[]
},
methods:{
run:function () {
alert(1);
},
show:function () {
alert(1);
},
runs:function () {
this.$http.get("http://127.0.0.1:5000/order",{
params:{
type:"Latte"
},
}).then(function (value) {
console.log(value)
})
},
post:function () {
this.$http.post("http://127.0.0.1:5000/order",
{
type:"Latte"
},
{emulateJSON:true}
).then(function (value) {
console.log(value);
})
},
testb:function () {
this.$http.jsonp("https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su",{
params:{
wd:this.str
},
jsonp:"cb"
}).then(function (value) {
this.arr = value.body.s;
})
}
},
computed:{
b:function () {
return this.msg;
}
},
create:function () {
console.log('after Vue create');
},
beforeMount:function () {
console.log("el created");
},
mounted:function () {
console.log("after");
},
beforeUpdate:function () {
console.log("before chage");
},
updated:function () {
console.log("change");
},
beforeDestroy:function () {
console.log("before destroy");
},
destroyed:function () {
console.log("destroyed");
}
})
</script>
</body>
</html>