router.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. Vue.use(Router);
  4. const routes = [
  5. {
  6. path: '/captcha/captcha',
  7. name: 'captcha',
  8. component: () => import('./view/captcha/captcha'),
  9. meta: {
  10. title: '获取验证码'
  11. }
  12. },
  13. {
  14. path: '*',
  15. name: 'login',
  16. component: () => import('./view/captcha/captcha'),
  17. meta: {
  18. title: '获取验证码'
  19. }
  20. },
  21. ];
  22. // add route path
  23. routes.forEach(route => {
  24. route.path = route.path || '/' + (route.name || '');
  25. });
  26. const router = new Router(
  27. {
  28. mode: 'history',
  29. routes
  30. });
  31. // const whiteList = [
  32. // 'login',
  33. // 'stafflogin',
  34. // 'invitation',
  35. // 'next',
  36. // 'join',
  37. // 'xiapu',
  38. // 'talentExchange',
  39. // 'captcha',
  40. // 'captchaLg',
  41. // ]
  42. router.beforeEach((to, from, next) => {
  43. const title = to.meta && to.meta.title;
  44. if (title) {
  45. document.title = title;
  46. }
  47. next()
  48. });
  49. export {
  50. router
  51. };