forked from tushargugnani/learningVueJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshopping-app.html
70 lines (66 loc) · 2.28 KB
/
shopping-app.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shopping App</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
.removed {
color: gray;
}
.removed label {
text-decoration: line-through;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6">
<div id="app">
<h3>Shopping List</h3><br/>
<input class="form-control" v-model="newItem" name="newItem" placeholder="Add New Item" @keyup.enter="addItem" />
<ul class="list-group">
<li class="list-group-item" v-for="item in items" :class="{'removed' : item.checked}">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" v-model="item.checked">
<label class="form-check-label" for="defaultCheck1">
{{item.text}}
</label>
</div>
</li>
</ul><br/>
<br/><br/>
</div>
</div>
</div>
</div>
</body>
<script>
let app = new Vue({
el : '#app',
data:{
items: [
{text : 'Banana', checked : false},
{text : 'Oranges', checked : false},
{text : 'Mangoes', checked : false},
],
newItem: '',
},
methods: {
addItem() {
var text;
text = this.newItem.trim();
if(text){
this.items.push({text: this.newItem, checked: false});
this.newItem = ''
}
}
}
});
</script>
</html>