index.js 854 Bytes
const routes = [
    {
        path: '/',
        name: 'home',
        component: () => myImport('views/home/index')
    },
    {
        path: '/services',
        name: 'services',
        component: () => myImport('views/services/index')
    },
    {
        path: '/about',
        name: 'about',
        component: () => myImport('views/about/index')
    },
    {
        path: '/concat',
        name: 'concat',
        component: () => myImport('views/concat/index')
    }
];

const router = VueRouter.createRouter({
    history: VueRouter.createWebHashHistory(),
    routes
});


router.beforeEach(async (to, from, next) => {
    $('[top-nav]').removeClass('current');
    $('[top-nav="'+to.name+'"]').addClass('current');
    // 回到顶部
    $('html, body').animate({
        scrollTop: 0
    }, 500);
    next();
})

export default router