-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
188 lines (179 loc) · 4.34 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
{{ message }}
</div>
<div id="app1">
{{message}}
</div>
<!--
double way data binding in Vue
It is achieved by new directive v-model,
the value of text box value to data property og Vue instance. -->
<div id='app3'>
<h3> Your Name is: {{name}}</h3>
<input type="text" v-model="name"/>
</div>
<!-- iteration through numbers -->
<div id="app4">
<ol>
<li v-for="n in 5">{{n}}</li>
</ol>
</div>
<!-- iterations through array of data from the data property of vue app -->
<div id="app5">
<ol>
<li v-for="n in countdown">{{n}}</li>
</ol>
</div>
<!-- for iteration with items index -->
<div id="app6">
<ol>
<li v-for="(fruit,i) in fruits">{{i}}--- {{fruit}}</li>
</ol>
</div>
<!-- loop through object property -->
<div id="app7">
<ul>
<li v-for="(value,key,index) in profile">{{key}}--{{value}}</li>
</ul>
</div>
<!-- for conditionals using if , end if -->
<div id = "app8">
<div v-if="count>10">
Count if greater then 10
</div>
<div v-else-if="count==10">
Count is 10
</div>
<div v-else>
Count is less than 10
</div>
<!-- using v-show -->
<div id = "app8">
<div v-show="count>10">
Count if greater then 10
</div>
<div v-show="count==10">
Count is 10
</div>
<div v-show>
Count is less than 10
</div>
</div>
<!-- Dynamic Data Binding -->
<div id="app9">
<h3 v-bind:class="{active:isActive}">This is dynamic binding</h3>
</div>
<!-- button binding -->
<div id="app10" class="container">
<p>
<button :disabled="disabled" @click="disabled=!disabled">
Disable me
</button>
<a href="#" @click.prevent="disabled=false">Enable Back</a>
</p>
</div>
<!-- for event handling -->
<div id='app11'>
<h2>{{count}}</h2>
<button v-on:click="count += 1"> Increase count</button>
<button v-on:click="count -= 1"> Decrease count</button>
</div>
</body>
<script type="text/javascript">
// for hello world example
var app = new Vue({
el: '#app',
data: {
message: 'Hello World!'
}
});
//for two vuw instances in single page
var app = new Vue({
el: '#app1',
data: {
message: 'Hi Again!'
}
});
// for double way data binding
var app = new Vue({
el: '#app3',
data:{
name:'kevin'
}
});
// for iteration through numbers
var app = new Vue({
el: '#app4',
});
// for iterations through array
var app = new Vue({
el: '#app5',
data:{
countdown:[7,8,12,45,15,16,14],
},
});
//For list of array with index notations
var app = new Vue({
el: '#app6',
data:{
fruits:["Bunana","Kakro","Ghiura","Apple","Pie"],
},
});
var app = new Vue({
el: '#app7',
data:{
profile:{
name:"Ram",
age:"31",
degree:"Masters",
position:"Full Stack development"
},
}
});
//for conditionals
var app = new Vue({
el:"#app8",
data:{
count:10,
}
})
//for dynamic data binding
var app = new Vue({
el:'#app9',
data:{
isActive: true
}
})
//for button binding
var app = new Vue({
el:'#app10',
data:{
disabled:false
}
})
var app = new Vue({
el:'#app11',
data:{
count:0
},
})
</script>
</html>
<style>
.active{
color:green;
}
.notActive{
color:blue;
}
</style>