index.js 760 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import Layout from '@/layout'
  4. Vue.use(VueRouter)
  5. const routes = [
  6. {
  7. path: '/',
  8. component: Layout,
  9. children: [
  10. {
  11. path: '',
  12. name: 'Index',
  13. component: () => import('@/views/Home/HomeIndex.vue'),
  14. meta: {
  15. title: '首页'
  16. }
  17. }
  18. ]
  19. },
  20. {
  21. path: '/login',
  22. name: 'Login',
  23. component: () => import('@/views/Login/LoginIndex.vue'),
  24. meta: {
  25. title: '登录'
  26. }
  27. }
  28. ]
  29. const router = new VueRouter({
  30. mode: 'history',
  31. routes
  32. })
  33. router.beforeEach((to, from, next) => {
  34. /* 路由发生变化修改页面title */
  35. if (to.meta.title) {
  36. document.title = to.meta.title
  37. }
  38. next()
  39. })
  40. export default router