modified
This commit is contained in:
68
src/router/index.js
Executable file
68
src/router/index.js
Executable file
@@ -0,0 +1,68 @@
|
||||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
// import Recommend from "views/recommend/Recommend.vue"
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
const VueRouterPush = VueRouter.prototype.push
|
||||
VueRouter.prototype.push = function push(to) {
|
||||
return VueRouterPush.call(this, to).catch(err => err)
|
||||
}
|
||||
//标题js
|
||||
import getPageTitle from "@/utils/title-config";
|
||||
|
||||
|
||||
const Index = () => import('views/index')
|
||||
const Recommend = () => import('views/recommend/Recommend')
|
||||
const Collect = () => import('views/collect/Collect')
|
||||
const AllSections = () => import('views/allSections/AllSections')
|
||||
|
||||
const routes = [
|
||||
{
|
||||
// 首页
|
||||
path: '/',
|
||||
name: 'Index',
|
||||
redirect: "/recommend",
|
||||
component: Index,
|
||||
children: [
|
||||
{
|
||||
path: '/recommend',
|
||||
name: 'Recommend',
|
||||
component: Recommend,
|
||||
meta: {
|
||||
title: "推荐版块"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/collect',
|
||||
name: 'Collect',
|
||||
component: Collect,
|
||||
meta: {
|
||||
title: "收藏的版块"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/allSections',
|
||||
name: 'AllSections',
|
||||
component: AllSections,
|
||||
meta: {
|
||||
title: "全部版块"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
})
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.meta.title) document.title = getPageTitle(to.meta.title);
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user