Skip to content

Commit e8d7ad2

Browse files
committed
product lines + product details work
1 parent dbc6161 commit e8d7ad2

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

cli-socks/src/components/Product.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ import ProductReview from './ProductReview.vue';
6868
export 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

cli-socks/src/components/ProductLine.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

cli-socks/src/store.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Vue.use(Vuex);
55

66

77
const 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: {

0 commit comments

Comments
 (0)