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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
| import Vue from 'vue'
| import Router from 'vue-router'
| import getPageTitle from '@/utils/get-page-title'
|
| Vue.use(Router)
|
| /* 总布局 */
| // import Layout from '@/layout'
|
| /**
| * 路由注册
| */
| export const constantRoutes = [
| {
| path: '/404',
| component: () => import('@/views/error-page/404'),
| meta: { title: '404' }
| },
| {
| path: '/building',
| component: () => import('@/views/error-page/building'),
| meta: { title: '网站建设中...' }
| },
| {
| path: '/music_cn',
| component: () => import('@/views/music/music_china'),
| meta: { title: '中国音乐...'}
| },
| {
| path: '/',
| component: () => import('@/views/home/index'),
| meta: { title: '强军网-首页' }
| },
| { path: '*', redirect: '/building', hidden: true }
| ]
|
| const createRouter = () => new Router({
| mode: 'history',
| scrollBehavior: () => ({ y: 0 }),
| routes: constantRoutes
| })
|
| const router = createRouter()
|
| // watch router change
| router.beforeEach(async(to, from, next) => {
| // set page title
| document.title = getPageTitle(to.meta.title)
| next()
| })
|
| router.afterEach(() => {
| // pass
| })
|
| export default router
|
|