Posts

Showing posts with the label 4). Vue.JS Routing Example

4). Vue.JS Routing Example

We are creating a single-page application with Vue + Vue Router. When we add Vue Router, all we need to do is map our components to the routes and  let Vue Router know where to render them. Here's a basic example: HTML <script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script> <div id="app"> <h1>Vue Router App!</h1> <p> <!-- use router-link component for navigation. --> <!-- specify the link by passing the `to` prop. --> <!-- <router-link> will be rendered as an `<a>` tag by default --> <router-link to="/foo">Home page</router-link> <router-link to="/bar">About Us</router-link> <router-link to="/bar">Contact Us</router-link> </p> <!-- component matched by the route will render here --...