Skip to content

Commit def343f

Browse files
committed
Added named view
1 parent e2df58c commit def343f

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

src/App.vue

+24-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
<template>
2-
<div class="container">
3-
<nav class="navbar navbar-default">
4-
<div class="container-fluid">
5-
<div class="navbar-header">
6-
<router-link to="/" exact class="navbar-brand"><strong>E-commerce Inc.</strong></router-link>
7-
</div>
2+
<div>
3+
<router-view name="discount"></router-view>
4+
5+
<div class="container">
6+
<nav class="navbar navbar-default">
7+
<div class="container-fluid">
8+
<div class="navbar-header">
9+
<router-link to="/" exact class="navbar-brand"><strong>E-commerce Inc.</strong></router-link>
10+
</div>
811

9-
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
10-
<ul class="nav navbar-nav">
11-
<router-link to="/" tag="li" exact active-class="active">
12-
<a>Products</a>
13-
</router-link>
12+
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
13+
<ul class="nav navbar-nav">
14+
<router-link to="/" tag="li" exact active-class="active">
15+
<a>Products</a>
16+
</router-link>
1417

15-
<router-link to="/cart" tag="li" active-class="active">
16-
<a>Cart</a>
17-
</router-link>
18-
</ul>
18+
<router-link to="/cart" tag="li" active-class="active">
19+
<a>Cart</a>
20+
</router-link>
21+
</ul>
1922

20-
<div class="nav navbar-nav navbar-right">
21-
<div class="stats">{{ cart.items.length }} <template v-if="cart.items.length == 1">item</template><template v-else>items</template> in cart, totalling {{ cartTotal | currency }}</div>
23+
<div class="nav navbar-nav navbar-right">
24+
<div class="stats">{{ cart.items.length }} <template v-if="cart.items.length == 1">item</template><template v-else>items</template> in cart, totalling {{ cartTotal | currency }}</div>
25+
</div>
2226
</div>
2327
</div>
24-
</div>
25-
</nav>
28+
</nav>
2629

27-
<router-view :cart="cart"></router-view>
30+
<router-view :cart="cart"></router-view>
31+
</div>
2832
</div>
2933
</template>
3034

src/SpecialOffer.vue

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div class="container-fluid">
3+
<div class="container">
4+
<div class="row">
5+
<div class="col-xs-12">
6+
<strong>Hurry up and get a discount of 20% by clicking an image!</strong>
7+
</div>
8+
</div>
9+
</div>
10+
</div>
11+
</template>
12+
13+
<style scoped>
14+
.container-fluid {
15+
height: 40px;
16+
color: #fff;
17+
line-height: 40px;
18+
text-align: center;
19+
background-color: orange;
20+
}
21+
</style>

src/routes.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ import ViewProduct from './ViewProduct.vue';
33
import Cart from './Cart.vue';
44
import Product from './Product.vue';
55
import ProductReviews from './ProductReviews.vue';
6+
import SpecialOffer from './SpecialOffer.vue';
67

78
export const routes = [
8-
{ path: '', component: ProductList },
9+
{ path: '', components: {
10+
default: ProductList,
11+
discount: SpecialOffer
12+
} },
913
{ path: '/products/:productId', name: 'product', props: true, component: Product, children: [
1014
{ path: 'details', name: 'viewProduct', props: true, component: ViewProduct },
1115
{ path: 'reviews', name: 'productReviews', props: true, component: ProductReviews }

0 commit comments

Comments
 (0)