Skip to content

Commit 3e23c8a

Browse files
authored
Merge pull request #19 from kkj930/master
4A Add a product price
2 parents dbd98be + 1f5fb50 commit 3e23c8a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cli-socks/src/components/Product.vue

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<div class="product-info">
88
<h1>
9-
{{ product.name }}
9+
{{ title }}
1010
<!-- eslint-disable-next-line vue/no-unused-vars -->
1111
<i v-for="i in averageReviewScore" class="fa fa-star" :key="i"></i>
1212
</h1>
@@ -56,13 +56,14 @@ export default class Product extends Vue {
5656
product = {
5757
name: "Vue Socks",
5858
brand: "Vue",
59+
price: 5,
5960
variants: [
6061
{id: 1, color: "green"},
6162
{id: 2, color: "blue"}
6263
],
6364
inventory: 3,
6465
reviews: []
65-
}
66+
};
6667
6768
selectedVariantIndex = 0;
6869
@@ -77,6 +78,10 @@ export default class Product extends Vue {
7778
return Math.round(this.product.reviews.reduce((a, c) => a + c, 0) / this.product.reviews.length);
7879
}
7980
81+
get title() {
82+
return `${this.product.name} ($${this.product.price})`;
83+
}
84+
8085
addToCart() {
8186
this.product.inventory--;
8287
const selectedVariant = this.product.variants[this.selectedVariantIndex];

0 commit comments

Comments
 (0)