commit | author | age
|
d3f921
|
1 |
import Vue from 'vue'; |
I |
2 |
import Router from 'vue-router' |
|
3 |
|
|
4 |
import { |
|
5 |
constantRouterMap, |
|
6 |
asyncRouterMap |
|
7 |
} from '@/config/router.config.js' |
|
8 |
|
|
9 |
|
|
10 |
Vue.use(Router) |
|
11 |
|
|
12 |
/*实例化路由*/ |
|
13 |
const router = new Router({ |
|
14 |
mode: "history", //模式修改 |
b505f3
|
15 |
routes: asyncRouterMap, |
I |
16 |
scrollBehavior (to, from, savedPosition) { |
|
17 |
|
|
18 |
//路由切换是否滚动到顶部 |
|
19 |
if (savedPosition) { |
|
20 |
return savedPosition |
|
21 |
} else { |
|
22 |
return { x: 0, y: 0 } |
|
23 |
} |
|
24 |
} |
d3f921
|
25 |
}) |
I |
26 |
|
|
27 |
router.beforeEach((to, from, next) => { |
56a4b8
|
28 |
window.document.title = to.meta.title == undefined?'在你左边,听风及雨':to.meta.title |
d3f921
|
29 |
next(); |
I |
30 |
}) |
|
31 |
|
|
32 |
|
|
33 |
/*导出路由模块*/ |
|
34 |
export default router |