File tree 3 files changed +11
-3
lines changed
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';
68
68
export default class Product extends Vue {
69
69
@Prop ({default: false }) private premium! : boolean ;
70
70
@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
+ }
72
77
73
78
selectedVariantIndex = 0 ;
74
79
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<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 >
4
4
</div >
5
5
</template >
6
6
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Vue.use(Vuex);
5
5
6
6
7
7
const productList = [ {
8
+ id : 1 ,
8
9
name : "Vue Socks" ,
9
10
brand : "Vue" ,
10
11
price : 5 ,
@@ -15,6 +16,7 @@ const productList = [{
15
16
reviews : [ ]
16
17
} ,
17
18
{
19
+ id : 2 ,
18
20
name : "Angular Socks" ,
19
21
brand : "Angular" ,
20
22
price : 15 ,
@@ -25,6 +27,7 @@ const productList = [{
25
27
reviews : [ ]
26
28
} ,
27
29
{
30
+ id : 3 ,
28
31
name : "npm Socks" ,
29
32
brand : "npm" ,
30
33
price : 3 ,
@@ -46,7 +49,7 @@ export default new Vuex.Store({
46
49
47
50
} ,
48
51
getters : {
49
-
52
+
50
53
} ,
51
54
52
55
mutations : {
You can’t perform that action at this time.
0 commit comments