Skip to content

Commit 5ecdbeb

Browse files
authored
Merge branch 'master' into master
2 parents 1adf272 + e759b1b commit 5ecdbeb

File tree

7 files changed

+78
-7
lines changed

7 files changed

+78
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
package-lock.json
33
Exercises.pdf
4+
.idea/

cli-socks/src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
<div class="links">
77
<router-link to="/">Home</router-link> |
8-
<router-link to="/counter" title="Vuex example">Counter</router-link>
8+
<router-link to="/counter" title="Vuex example">Counter</router-link> |
9+
<router-link to="/cart" title="Cart summary">Cart</router-link>
910
</div>
1011
</div>
1112

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<div>{{product.name}}
3+
<router-link :to="{ name: 'product', params: { id: product.name }}">Link</router-link>
4+
</div>
5+
</template>
6+
7+
8+
<script lang="ts">
9+
import { Component, Prop, Vue } from "vue-property-decorator";
10+
import { ProductModel } from '../models';
11+
12+
@Component({
13+
components: {
14+
}
15+
})
16+
17+
export default class ProductLine extends Vue {
18+
@Prop({default: undefined}) private product!: ProductModel;
19+
}
20+
</script>
21+
22+
<style scoped>
23+
24+
</style>

cli-socks/src/models.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export class ProductModel {
2+
name: string = "";
3+
brand: string = "";
4+
variants: [
5+
// {id: 1, color: "green"},
6+
// {id: 2, color: "blue"}
7+
] = [];
8+
inventory: number = 0;
9+
reviews: [] = [];
10+
}

cli-socks/src/router.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Vue from "vue";
22
import Router from "vue-router";
33
import Home from "./views/Home.vue";
4+
import Product from "./components/Product.vue";
45

6+
import Cart from "./views/Cart.vue";
57
Vue.use(Router);
68

79
export default new Router({
@@ -21,6 +23,16 @@ export default new Router({
2123
// which is lazy-loaded when the route is visited.
2224
component: () => import(/* webpackChunkName: "counter" */ "./views/Counter.vue")
2325
},
26+
{
27+
name: 'product',
28+
path: '/product/:id',
29+
component: Product
30+
},
31+
{
32+
path: "/cart",
33+
name: "cart",
34+
component: Cart
35+
},
2436
// {
2537
// path: '/product/:id',
2638
// component: () => import(/* webpackChunkName: "productDetail" */ "./views/ProductPage.vue")

cli-socks/src/views/Cart.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div>
3+
HELLO FROM THE CART
4+
</div>
5+
6+
</template>
7+
8+
<script>
9+
import {Component, Vue} from "vue-property-decorator";
10+
11+
@Component({
12+
components: {}
13+
})
14+
export default class Cart extends Vue {
15+
16+
}
17+
</script>
18+
19+
<style scoped>
20+
21+
</style>

cli-socks/src/views/Home.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<template>
22
<div>
3-
<Product v-for="product in products"
3+
4+
<ProductLine v-for="product in products"
45
:key="product.brand"
5-
:premium="premium"
66
:product="product"
7-
@add-to-cart="updateCart"
8-
@remove-from-cart="removeFromCart"
9-
:cartLength="cart.length"></Product>
7+
></ProductLine>
108

119
<div class="cart">
1210
{{ cart.length }}
@@ -18,13 +16,17 @@
1816
<script lang="ts">
1917
import { Component, Vue } from "vue-property-decorator";
2018
import Product from "../components/Product.vue";
19+
import ProductLine from "../components/ProductLine.vue";
20+
import { ProductModel } from '../models';
2121
2222
@Component({
2323
components: {
24-
Product
24+
Product,
25+
ProductLine
2526
}
2627
})
2728
export default class Home extends Vue {
29+
2830
premium = true;
2931
cart: string[] = [];
3032

0 commit comments

Comments
 (0)