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 11node_modules
22package-lock.json
33Exercises.pdf
4+ .idea /
Original file line number Diff line number Diff line change 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
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 11import Vue from "vue" ;
22import Router from "vue-router" ;
33import Home from "./views/Home.vue" ;
4+ import Product from "./components/Product.vue" ;
45
6+ import Cart from "./views/Cart.vue" ;
57Vue . use ( Router ) ;
68
79export 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")
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 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 }}
1816<script lang="ts">
1917import { Component , Vue } from " vue-property-decorator" ;
2018import 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})
2728export default class Home extends Vue {
29+
2830 premium = true ;
2931 cart: string [] = [];
3032
You can’t perform that action at this time.
0 commit comments