Main.js File

From rbachwiki
Jump to navigation Jump to search
import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router';
import { myRoutes } from './routes.js';


Vue.use(VueRouter);

const router = new VueRouter({
    routes: myRoutes,
    mode: 'history',
    scrollBehavior(to, from, savedPosition){
        if(savedPosition){
            return savedPosition;
        }
        if(to.hash){
            return{selector: to.hash};
        }
        //return{x:0 , y:700};
    }
});
// get executed on each routing action
router.beforeEach((to, from, next) =>{
console.log('Global before each');
next();
});

new Vue({
    el: '#app',
    router,
    render: h => h(App)
})

VueJs Routing