'!'
This commit is contained in:
53
src/router/index.js
Normal file
53
src/router/index.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
// 路由懒加载
|
||||
const Home = () => import('@/views/home/Home')
|
||||
const DownLoad = () => import('@/views/download/downLoad')
|
||||
|
||||
const routes = [
|
||||
// 重定向到首页
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/home',
|
||||
},
|
||||
|
||||
// 首页
|
||||
{
|
||||
path: '/home',
|
||||
name: 'Home',
|
||||
meta: {
|
||||
title: '首页'
|
||||
},
|
||||
component: Home
|
||||
},
|
||||
|
||||
// 下载软件
|
||||
{
|
||||
path: '/downLoad',
|
||||
name: 'DownLoad',
|
||||
meta: {
|
||||
title: '软件下载'
|
||||
},
|
||||
component: DownLoad
|
||||
}
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.title) {
|
||||
document.title = to.meta.title;
|
||||
}
|
||||
if (to.name !== from.name) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user