11Vue . component ( 'product-review' , {
2- props : [ 'averageReviewScore' ] ,
32 template : `
43 <form class="review-form" @submit.prevent="onSubmit">
5- <h3 v-if="averageReviewScore">Score: {{ averageReviewScore }}</h3>
64 <h3>Add Review</h3>
75 <label>Name</label>
86 <input v-model="name">
@@ -42,6 +40,7 @@ Vue.component('product-review', {
4240
4341
4442
43+
4544
4645Vue . component ( 'product' , {
4746 props : {
@@ -54,7 +53,10 @@ Vue.component('product', {
5453 </div>
5554
5655 <div class="product-info">
57- <h1>{{ product }}</h1>
56+ <h1>
57+ {{ product }}
58+ <i v-for="i in averageReviewScore" class="fa fa-star"></i>
59+ </h1>
5860
5961 <div>
6062 <p v-if="inventory > 10">In Stock</p>
@@ -79,11 +81,8 @@ Vue.component('product', {
7981 :style="{backgroundColor: variant.color}"
8082 @mouseover="selectedVariantIndex = index">
8183 </div>
82-
83- <product-review
84- @add-review="addReview"
85- :averageReviewScore="averageReviewScore"
86- ></product-review>
84+
85+ <product-review @add-review="addReview"></product-review>
8786 </div>
8887 </div>
8988 ` ,
@@ -106,7 +105,7 @@ Vue.component('product', {
106105 this . $emit ( 'add-to-cart' , { product : this . product , variant : selectedVariant } ) ;
107106 } ,
108107 addReview ( review ) {
109- console . log ( 'addReview' , review ) ;
108+ this . reviews . push ( review . rating ) ;
110109 }
111110 } ,
112111 computed : {
0 commit comments