1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Vue Basics</ title >
6+ < link rel ="stylesheet " href ="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css " integrity ="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO " crossorigin ="anonymous ">
7+ </ head >
8+ < body >
9+
10+ < div id ="app ">
11+ < div class ="container ">
12+ < div class ="card mt-5 ">
13+ < h3 class ="card-title card-header bg-info text-light text-center "> 04 - Directives</ h3 >
14+ < div class ="card-body ">
15+ < div v-if ="product.quantityInStock > 0 ">
16+ < p > Product Name: {{ product.name }}</ p >
17+
18+ < p v-show ="showDescription "> Description: {{ product.description }}</ p >
19+
20+ < p v-if ="product.quantityInStock < 3 " class ="bg-danger p-1 ">
21+ {{ product.quantityInStock }} left, we're almost sold out
22+ </ p >
23+
24+ < p v-else-if ="product.quantityInStock >= 3 && product.quantityInStock <= 5 " class ="bg-warning p-1 ">
25+ {{ product.quantityInStock }} left, stock is running low
26+ </ p >
27+
28+ < p v-else class ="bg-success p-1 ">
29+ {{ product.quantityInStock }} left
30+ </ p >
31+
32+ < p > On Sale? {{ product.isOnSale ? 'YES' : 'NO' }}</ p >
33+ < p > Sale Price {{ product.price }}</ p >
34+ </ div >
35+
36+ < div v-else >
37+ Sorry, the {{ product.name }} is out of stock.
38+ </ div >
39+ </ div >
40+ </ div >
41+ </ div >
42+ < div class ="m-3 " style ="width: 300px ">
43+ < div class ="form-group ">
44+ < label > Quantity In Stock</ label >
45+ < input v-model ="product.quantityInStock " type ="text " class ="form-control ">
46+ </ div >
47+ < div class ="form-group form-check ">
48+ < input v-model ="product.isOnSale " type ="checkbox " class ="form-check-input ">
49+ < label class ="form-check-label "> On Sale?</ label >
50+ </ div >
51+ < div class ="form-group form-check ">
52+ < input v-model ="showDescription " type ="checkbox " class ="form-check-input ">
53+ < label class ="form-check-label "> Show Description?</ label >
54+ </ div >
55+ </ div >
56+ </ div >
57+
58+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.8/vue.js "> </ script >
59+ < script >
60+ new Vue ( {
61+ el : '#app' ,
62+ data : {
63+ product : {
64+ name : 'Super Widget' ,
65+ quantityInStock : 1 ,
66+ isOnSale : true ,
67+ price : '$19.95' ,
68+ description : 'Heu. Calceuss favere! Toruss trabem in camerarius cubiculum! Bassus particulas ducunt ad boreas.'
69+ } ,
70+ showDescription : false
71+ }
72+ } )
73+ </ script >
74+ </ body >
75+ </ html >
0 commit comments