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

(singke) #1
Introducing Vue-Router and Loading URL-Based Components Chapter 8

The alias key gets added to an existing route and accepts just a string of the path. Using the


preceding example, the following will show the About component, whether the user visits


/about or /about-us:


const router = new VueRouter({
routes: [
{
path: '/',
component: Home
},
{
path: '/about',
alias: '/about-us',
component: About,
},
{
path: '*',
component: PageNotFound
}
],

linkActiveClass: 'active',
linkExactActiveClass: 'current'
});

Summary


You should now be familiar with Vue-router, how to initialize it, what options are


available, and how to create new routes—both static and dynamic. In the next few chapters,


we'll begin creating our shop, starting with loading some shop data and creating a product


page.

Free download pdf