File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,12 @@ import ProductReview from './ProductReview.vue';
6868export default class Product extends Vue {
6969 @Prop ({default: false }) private premium! : boolean ;
7070 @Prop () private cartLength! : number ;
71- @Prop () private product! : any ;
71+
72+ get product(): any {
73+ const prodName = this .$route .params .id ;
74+ console .log (' prodName' , prodName );
75+ return this .$store .state .products .find ((x : any ) => x .id === prodName );
76+ }
7277
7378 selectedVariantIndex = 0 ;
7479
Original file line number Diff line number Diff line change 11<template >
22 <div >{{product.name}}
3- <router-link :to =" { name: 'product', params: { id: product.name }}" >Link</router-link >
3+ <router-link :to =" { name: 'product', params: { id: product.id }}" >Link</router-link >
44 </div >
55</template >
66
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Vue.use(Vuex);
55
66
77const productList = [ {
8+ id : 1 ,
89 name : "Vue Socks" ,
910 brand : "Vue" ,
1011 price : 5 ,
@@ -15,6 +16,7 @@ const productList = [{
1516 reviews : [ ]
1617} ,
1718{
19+ id : 2 ,
1820 name : "Angular Socks" ,
1921 brand : "Angular" ,
2022 price : 15 ,
@@ -25,6 +27,7 @@ const productList = [{
2527 reviews : [ ]
2628} ,
2729{
30+ id : 3 ,
2831 name : "npm Socks" ,
2932 brand : "npm" ,
3033 price : 3 ,
@@ -46,7 +49,7 @@ export default new Vuex.Store({
4649
4750 } ,
4851 getters : {
49-
52+
5053 } ,
5154
5255 mutations : {
You can’t perform that action at this time.
0 commit comments