Difference between revisions of "Main.js File"

From rbachwiki
Jump to navigation Jump to search
(Created page with "<nowiki>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...")
 
Line 1: Line 1:
<nowiki>import Vue from 'vue'
<pre>import Vue from 'vue'
import App from './App.vue'
import App from './App.vue'
import VueRouter from 'vue-router';
import VueRouter from 'vue-router';
Line 30: Line 30:
     router,
     router,
     render: h => h(App)
     render: h => h(App)
})</nowiki>
})</pre>

Revision as of 18:04, 17 October 2018

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)
})