Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1
Single Page Applications Chapter 15

If you don't specify a name, the route will be referred to as default:


routes: [
{ path: '/',
components: {
default: DefaultComponent,
view1: Component1,
view2: Component2
}
}
]

This way, the components will be displayed in their respective router-view elements.


If you don't specify one or more components for a named view, the
router-view associated with that name will be empty.

Compose your routes hierarchically


In many cases, the organization tree of your website may be complex. In some cases, there
is a clear hierarchical organization that you can follow and with nested routes, vue-routes


helps you keep everything orderly. The best situation is if there is an exact correspondence
with how URLs are organized and how components are nested.


Getting ready


In this recipe, you will use components and other basic features of Vue. You will also use


dynamic routes. Go to the Using named dynamic routes recipe to find out more about them.


How to do it...


In this recipe, you will build an online accounting website for an imaginary world. We will
have two users--Stark and Lannister--and we will be able to see how much gold and


how many soldier these two have.

Free download pdf