Answers for "how to add vue router to existing project"


installing vue router & implementation

//Installing Vue Router
npm install vue-router

//main.js - Add below lines
import VueRouter from 'vue-router';


const router = new VueRouter({
  mode: 'history'

new Vue({
  render: h => h(App)

//App.vue - Add below line in v-content

//route.js - We need to craate file under src
import linkName from './components/fileName.vue';
export const routes = [
    path: '/',
    component: linkName
Posted by: Guest on June-01-2020

add router to vue

vue add router # Vue CLI
Posted by: Guest on December-18-2020

router configuration vue

npm install --save vue-router

//after installing vue-router in the project
//go inside main.js in your project and add
//(just after Vue.config.productionTip=false):


const routes=[
{path: '/home', component: [componentName]},
{path: '/features', component: [componentName2]},
//you can add  as many routes as you need

//also add:

const router=new VueRouter({
mode: 'history'

//to make the router accesible for all the project you need to add it inside the new Vue:

new Vue({
router,     <----

//to make different pages acoording to the route selected, add (inside app.vue):
   <div id="app">

     <router-view> </router-view>  <----------
Posted by: Guest on October-31-2020

Code answers related to "how to add vue router to existing project"

Code answers related to "Javascript"

Browse Popular Code Answers by Language