L9 solution
This commit is contained in:
parent
40c519c162
commit
e5a0b6e460
17
components/ProductDetails.js
Normal file
17
components/ProductDetails.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// solution
|
||||||
|
app.component('product-details', {
|
||||||
|
props: {
|
||||||
|
details: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template:
|
||||||
|
/*html*/
|
||||||
|
`
|
||||||
|
<ul>
|
||||||
|
<li v-for="detail in details">{{ detail }}</li>
|
||||||
|
</ul>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
// solution
|
||||||
@ -14,9 +14,10 @@ app.component('product-display', {
|
|||||||
<p v-else>Out of Stock</p>
|
<p v-else>Out of Stock</p>
|
||||||
|
|
||||||
<p>Shipping: {{ shipping }}</p>
|
<p>Shipping: {{ shipping }}</p>
|
||||||
<ul>
|
|
||||||
<li v-for="detail in details">{{ detail }}</li>
|
<!-- solution -->
|
||||||
</ul>
|
<product-details :details="details"></product-details>
|
||||||
|
<!-- solution -->
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-for="(variant, index) in variants"
|
v-for="(variant, index) in variants"
|
||||||
@ -50,7 +51,7 @@ app.component('product-display', {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addToCart() {
|
addToCart() {
|
||||||
this.$emit('add-to-cart', this.variants[this.selectedVariant].id)
|
this.cart += 1
|
||||||
},
|
},
|
||||||
updateVariant(index) {
|
updateVariant(index) {
|
||||||
this.selectedVariant = index
|
this.selectedVariant = index
|
||||||
|
|||||||
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
<!-- Import Components -->
|
<!-- Import Components -->
|
||||||
<script src="./components/ProductDisplay.js"></script>
|
<script src="./components/ProductDisplay.js"></script>
|
||||||
|
<!-- solution -->
|
||||||
|
<script src="./components/ProductDetails.js"></script>
|
||||||
|
<!-- solution -->
|
||||||
|
|
||||||
<!-- Mount App -->
|
<!-- Mount App -->
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user