File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 11
11
<i v-for =" i in averageReviewScore" class =" fa fa-star" :key =" i" ></i >
12
12
</h1 >
13
13
14
- <div >All reviews:</div >
14
+ <div v-if = " product.reviews.length " >All reviews:</div >
15
15
<div v-for =" j in product.reviews" :key =" j.name+j.rating" >
16
16
<label >{{ j.name}}: </label >
17
17
<i v-for =" k in j.rating" class =" fa fa-star" :key =" k" ></i >
@@ -67,7 +67,7 @@ import ProductReview from './ProductReview.vue';
67
67
68
68
export default class Product extends Vue {
69
69
@Prop ({default: false }) private premium! : boolean ;
70
- @Prop () private cartLength: number ;
70
+ @Prop () private cartLength! : number ;
71
71
72
72
product = {
73
73
name: " Vue Socks" ,
@@ -91,7 +91,12 @@ export default class Product extends Vue {
91
91
if (! this .product .reviews .length ) {
92
92
return null ;
93
93
}
94
- return Math .round (this .product .reviews .map (x => x .rating ).reduce ((a , c ) => a + c , 0 ) / this .product .reviews .length );
94
+ const reviews = this .product .reviews as any ;
95
+ const totalStars = reviews
96
+ .map ((x : any ) => x .rating )
97
+ .reduce ((a : any , c : any ) => a + c , 0 );
98
+
99
+ return Math .round (totalStars / this .product .reviews .length );
95
100
}
96
101
97
102
get title() {
You can’t perform that action at this time.
0 commit comments