-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
100 lines (88 loc) · 3.89 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Jquery Demo</title>
</head>
<body>
<div class="container" id="app">
<div class="row">
<div class="col">
<h1 id="1st">{{framework}} Demo</h1>
<h1 id="2nd">Vue says hello {{name}}</h1>
</div>
</div>
<div class="row">
<div class="col" id="alert-col">
<input type="text" class="form-control" placeholder="What is your name?" v-model="name" />
<div class="alert alert-primary" role="alert">
A simple primary alert—check it out!
</div>
<button type="button" class="btn btn-primary" @click="click" >Primary</button>
<button type="button" class="btn btn-success" id="new" >Success</button>
</div>
<div class="col">
<div class="card" style="width: 18rem;">
<img src="https://media3.s-nbcnews.com/j/newscms/2019_35/2945101/190724-boris-johnson-queen-elizabeth-al-1045_968114a3317992bb3dca26dab6812e6f.focal-460x230.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Cart Total: ${{total}} </h5>
<p class="card-text" v-for="x in items">
<input style="width: 50%; float: left" v-model="x.name" placeholder="Item Name" />
<input style="width: 50%" v-model="x.price" placeholder="Price" />
</p>
<a href="#" class="btn btn-primary" @click.prevent="addItem" >Add Item</a>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
$(function(){
$("#new").on('click', function(){
console.log({
theAlert: $(".alert"),
theCol: $("#alert-col")
});
$(".alert").eq(0)
.clone().text("Some new text")
.appendTo("#alert-col");
})
})
</script>
<script>
var app = new Vue({
el: '#app',
data: {
framework: 'Vue',
name: null,
items: []
},
methods: {
click(){
this.framework = 'Used to be jQuery, but now it\'s Vue'
},
addItem(){
this.items.push({ name: '', price: 0.0 });
}
},
computed: {
total(){
return this.items.reduce( (prev, x) => prev + +x.price, 0 );
}
}
})
</script>
</body>
</html>