05b804a7cda86f84f8d4f390aa617d82958d71b9d6aff6ab19b73ac68fae2798592bd0a44a3066266405ad3406a71c5d7054f307f2515f4b1b7db79a6ba3ff 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { createRouter<%
  2. if (historyMode) {
  3. %>, createWebHistory<%
  4. } else {
  5. %>, createWebHashHistory<%
  6. }
  7. if (hasTypeScript) {
  8. %>, RouteRecordRaw<%
  9. }
  10. %> } from 'vue-router'
  11. import Home from '../views/Home.vue'
  12. const routes<% if (hasTypeScript) { %>: Array<RouteRecordRaw><% } %> = [
  13. {
  14. path: '/',
  15. name: 'Home',
  16. component: Home
  17. },
  18. {
  19. path: '/about',
  20. name: 'About',
  21. // route level code-splitting
  22. // this generates a separate chunk (about.[hash].js) for this route
  23. // which is lazy-loaded when the route is visited.
  24. <%_ if (doesCompile) { _%>
  25. component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  26. <%_ } else { _%>
  27. component: function () {
  28. return import(/* webpackChunkName: "about" */ '../views/About.vue')
  29. }
  30. <%_ } _%>
  31. }
  32. ]
  33. const router = createRouter({
  34. <%_ if (historyMode) { _%>
  35. history: createWebHistory(process.env.BASE_URL),
  36. <%_ } else { _%>
  37. history: createWebHashHistory(),
  38. <%_ } _%>
  39. routes
  40. })
  41. export default router