Linking in Vue

By | 29/01/2020

Having set up Vue Router, linking within th components is relatively straight forward.

In router.js ensure you’ve declared your routes, i.e.

const routes = [
    {   path: "/contact",
        component: Contact,
        name: "contact",
    },
    {
        path: "/about",
        component: About,
        name: "about",
    }];

You can then use router-link to embed a tags in your page

<router-link :to="{name: 'contact'}">Contact</router-link>

<router-link :to="{name: 'about'}">About</router-link>