File tree Expand file tree Collapse file tree 7 files changed +78
-7
lines changed Expand file tree Collapse file tree 7 files changed +78
-7
lines changed Original file line number Diff line number Diff line change 1
1
node_modules
2
2
package-lock.json
3
3
Exercises.pdf
4
+ .idea /
Original file line number Diff line number Diff line change 5
5
6
6
<div class =" links" >
7
7
<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 >
9
10
</div >
10
11
</div >
11
12
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 1
1
import Vue from "vue" ;
2
2
import Router from "vue-router" ;
3
3
import Home from "./views/Home.vue" ;
4
+ import Product from "./components/Product.vue" ;
4
5
6
+ import Cart from "./views/Cart.vue" ;
5
7
Vue . use ( Router ) ;
6
8
7
9
export default new Router ( {
@@ -21,6 +23,16 @@ export default new Router({
21
23
// which is lazy-loaded when the route is visited.
22
24
component : ( ) => import ( /* webpackChunkName: "counter" */ "./views/Counter.vue" )
23
25
} ,
26
+ {
27
+ name : 'product' ,
28
+ path : '/product/:id' ,
29
+ component : Product
30
+ } ,
31
+ {
32
+ path : "/cart" ,
33
+ name : "cart" ,
34
+ component : Cart
35
+ } ,
24
36
// {
25
37
// path: '/product/:id',
26
38
// component: () => import(/* webpackChunkName: "productDetail" */ "./views/ProductPage.vue")
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <Product v-for =" product in products"
3
+
4
+ <ProductLine v-for =" product in products"
4
5
:key =" product.brand"
5
- :premium =" premium"
6
6
:product =" product"
7
- @add-to-cart =" updateCart"
8
- @remove-from-cart =" removeFromCart"
9
- :cartLength =" cart.length" ></Product >
7
+ ></ProductLine >
10
8
11
9
<div class =" cart" >
12
10
{{ cart.length }}
18
16
<script lang="ts">
19
17
import { Component , Vue } from " vue-property-decorator" ;
20
18
import Product from " ../components/Product.vue" ;
19
+ import ProductLine from " ../components/ProductLine.vue" ;
20
+ import { ProductModel } from ' ../models' ;
21
21
22
22
@Component ({
23
23
components: {
24
- Product
24
+ Product ,
25
+ ProductLine
25
26
}
26
27
})
27
28
export default class Home extends Vue {
29
+
28
30
premium = true ;
29
31
cart: string [] = [];
30
32
You can’t perform that action at this time.
0 commit comments