-
Notifications
You must be signed in to change notification settings - Fork 0
/
index1.html
186 lines (179 loc) · 6.38 KB
/
index1.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
<!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">
<h2>Greet</h2>
<button v-on:click="greet('Hello')">Say Hello</button>
<button v-on:click="greet('Hi')">Say Hi</button>
<button v-on:click="greet('Namaste')">Say Namaste</button>
<br/><br/>
{{greeting}}
</div>
<!-- for event handling -->
<div id='app1'>
{{count}}
<button v-on:click="count += 1"> Increase count</button>
<button v-on:click="count -= 1"> Decrease count</button>
</div>
<div id='app2'>
<ul>
<li v-for='name in names'> {{name}}</li>
</ul>
<input type="text" v-model="message"/>
<button v-on:click="addName">Add Name</button>
</div>
<div id= 'app3'>
<label>Type your name:</label>
<input type='text' v-model="name"/>
Your name is {{name}}<br/>
And is {{charcount}} characters long.
</div>
<!-- filtering by using dropdown -->
<div id="app4">
<h3>Filter By Category</h3>
<select v-model="category">
<option valeu="Accessories">Accessories</option>
<option valeu="Laptop">Laptop</option>
<option valeu="Stationary">Stationary</option>
</select>
<ul>
<li v-for="product in filterProductsByCategory">Product Name : {{product.name}} - Price : {{product.price}} ({{product.category}})</li>
</ul>
</div>
<div id="app5">
<h3>Filter By Name</h3>
<input type="text" v-model="name" placeholder="Filter By Name"/>
<ul>
<li v-for="product in filterProductsByName">Product Name : {{product.name}} - Price : {{product.price}} ({{product.category}})</li>
</ul>
</div>
<div id="app6">
<h3>Filter By Price Range</h3>
<label for="vol">Price (between 0 and 1000):</label>
<input type="range" v-model="range" min="0" max="1000" step="10"/>
Selected : {{range}}
</div>
<!-- using the text box query -->
</body>
<script type="text/javascript">
var app = new Vue({
el:"#app",
data:{
greeting:"",
},
methods:{
greet:function(greeting){
this.greeting=greeting+ ",how are you ?";
}
}
});
var app = new Vue({
el:'#app1',
data:{
count:0
},
});
// displayed and added also the data from the input from user to the just
var app = new Vue({
el:'#app2',
data:{
names:['ram','shyam','hari','bharat','gita'],
message:""
},
methods:{
addName:function(){
this.names.push(this.message);
this.message='';
}
}
});
var app = new Vue({
el:'#app3',
data:{
name:"",
},
computed: {
charcount: function(){
return this.name.length;
}
}
});
// filtering by drop down
var app = new Vue({
el:"#app4",
data:{
category:'',
name:"",
products:[
{ name: "Keyboard", price: 44, category: 'Accessories'},
{ name: "Mouse", price: 20, category: 'Accessories'},
{ name: "Monitor", price: 399, category: 'Accessories'},
{ name: "Dell XPS", price: 599, category: 'Laptop'},
{ name: "MacBook Pro", price: 899, category: 'Laptop'},
{ name: "Pencil Box", price: 6, category: 'Stationary'},
{ name: "Pen", price: 2, category: 'Stationary'},
{ name: "USB Cable", price: 7, category: 'Accessories'},
{ name: "Eraser", price: 2, category: 'Stationary'},
{ name: "Highlighter", price: 5, category: 'Stationary'}
]
},
computed:{
filterProductsByCategory: function(){
return this.products.filter(product => !product.category.indexOf(this.category))
},
}
});
var app = new Vue({
el:"#app5",
data:{
name:"",
products:[
{ name: "Keyboard", price: 44, category: 'Accessories'},
{ name: "Mouse", price: 20, category: 'Accessories'},
{ name: "Monitor", price: 399, category: 'Accessories'},
{ name: "Dell XPS", price: 599, category: 'Laptop'},
{ name: "MacBook Pro", price: 899, category: 'Laptop'},
{ name: "Pencil Box", price: 6, category: 'Stationary'},
{ name: "Pen", price: 2, category: 'Stationary'},
{ name: "USB Cable", price: 7, category: 'Accessories'},
{ name: "Eraser", price: 2, category: 'Stationary'},
{ name: "Highlighter", price: 5, category: 'Stationary'}
]
},
computed:{
filterProductsByName: function() {
return this.products.filter(product => !product.name.indexOf(this.name))
},
}
});
var app = new Vue({
el:"#app6",
data:{
range:"500",
products:[
{ name: "Keyboard", price: 44, category: 'Accessories'},
{ name: "Mouse", price: 20, category: 'Accessories'},
{ name: "Monitor", price: 399, category: 'Accessories'},
{ name: "Dell XPS", price: 599, category: 'Laptop'},
{ name: "MacBook Pro", price: 899, category: 'Laptop'},
{ name: "Pencil Box", price: 6, category: 'Stationary'},
{ name: "Pen", price: 2, category: 'Stationary'},
{ name: "USB Cable", price: 7, category: 'Accessories'},
{ name: "Eraser", price: 2, category: 'Stationary'},
{ name: "Highlighter", price: 5, category: 'Stationary'}
]
},
computed:{
filterProductsByRange: function(){
return this.products.filter(product => (product.price > 0 && product.price < this.range) ? product : '')
}
},
});
</script>