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 >
@@ -58,6 +64,7 @@ import ProductReview from './ProductReview.vue';
5864 ProductReview
5965 }
6066})
67+
6168export default class Product extends Vue {
6269 @Prop ({default: false }) private premium! : boolean ;
6370 @Prop () private cartLength: number ;
@@ -84,7 +91,7 @@ export default class Product extends Vue {
8491 if (! this .product .reviews .length ) {
8592 return null ;
8693 }
87- return Math .round (this .product .reviews .reduce ((a , c ) => a + c , 0 ) / this .product .reviews .length );
94+ return Math .round (this .product .reviews .map ( x => x . rating ). reduce ((a , c ) => a + c , 0 ) / this .product .reviews .length );
8895 }
8996
9097 get title() {
@@ -105,7 +112,7 @@ export default class Product extends Vue {
105112
106113 addReview(review : any ) {
107114 const reviews = this .product .reviews as any ;
108- reviews .push (review . rating );
115+ reviews .push (review );
109116 }
110117}
111118 </script >
You can’t perform that action at this time.
0 commit comments