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: '/music_world', component: () => import('@/views/music/music_word'), meta: { title: '世界音乐...' } }, { path: '/film_cn', component: () => import('@/views/film/film_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