L9 solution

This commit is contained in:
Adam Jahr 2020-07-21 00:48:15 -04:00
parent 40c519c162
commit e5a0b6e460
4 changed files with 26 additions and 9 deletions

View 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

View File

@ -14,9 +14,10 @@ app.component('product-display', {
<p v-else>Out of Stock</p>
<p>Shipping: {{ shipping }}</p>
<ul>
<li v-for="detail in details">{{ detail }}</li>
</ul>
<!-- solution -->
<product-details :details="details"></product-details>
<!-- solution -->
<div
v-for="(variant, index) in variants"
@ -50,7 +51,7 @@ app.component('product-display', {
},
methods: {
addToCart() {
this.$emit('add-to-cart', this.variants[this.selectedVariant].id)
this.cart += 1
},
updateVariant(index) {
this.selectedVariant = index

View File

@ -21,6 +21,9 @@
<!-- Import Components -->
<script src="./components/ProductDisplay.js"></script>
<!-- solution -->
<script src="./components/ProductDetails.js"></script>
<!-- solution -->
<!-- Mount App -->
<script>

View File

@ -5,9 +5,5 @@ const app = Vue.createApp({
premium: true
}
},
methods: {
updateCart(id) {
this.cart.push(id)
}
}
methods: {}
})