File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1111 <i v-for =" i in averageReviewScore" class =" fa fa-star" :key =" i" ></i >
1212 </h1 >
1313
14+ <div >All reviews:</div >
15+ <div v-for =" j in product.reviews" :key =" j.name+j.rating" >
16+ <label >{{ j.name}}: </label >
17+ <i v-for =" k in j.rating" class =" fa fa-star" :key =" k" ></i >
18+ </div >
19+
1420 <div >
1521 <p v-if =" product.inventory > 10" >In Stock</p >
1622 <p v-else-if =" product.inventory" >Almost sold out</p >
@@ -50,6 +56,7 @@ import ProductReview from './ProductReview.vue';
5056 ProductReview
5157 }
5258})
59+
5360export default class Product extends Vue {
5461 @Prop ({default: false }) private premium! : boolean ;
5562
@@ -74,7 +81,7 @@ export default class Product extends Vue {
7481 if (! this .product .reviews .length ) {
7582 return null ;
7683 }
77- return Math .round (this .product .reviews .reduce ((a , c ) => a + c , 0 ) / this .product .reviews .length );
84+ return Math .round (this .product .reviews .map ( x => x . rating ). reduce ((a , c ) => a + c , 0 ) / this .product .reviews .length );
7885 }
7986
8087 addToCart() {
@@ -85,7 +92,7 @@ export default class Product extends Vue {
8592
8693 addReview(review : any ) {
8794 const reviews = this .product .reviews as any ;
88- reviews .push (review . rating );
95+ reviews .push (review );
8996 }
9097}
9198 </script >
You can’t perform that action at this time.
0 commit comments