How it works…

When adding the <router-view> components to the page, you just have to remember to add a name to refer to it later during route registration:

<router-view name="view1"></router-view><router-view name="view2"></router-view><router-view></router-view>

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.

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.