index.js
854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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