router.ts 817 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
  2. import Home from "./view-detail/index";
  3. import Notfind from "../view/notfind";
  4. const routes: RouteRecordRaw[] = [
  5. {
  6. path: "/",
  7. component: Home,
  8. },
  9. {
  10. path: "/product-img",
  11. component: () => import("./view-product-img/index"),
  12. },
  13. {
  14. path: "/evaluat-report",
  15. component: () => import("./view-evaluat-report/index"),
  16. },
  17. {
  18. path: "/:pathMatch(.*)*",
  19. component: Notfind,
  20. meta: {
  21. title: "404 Not Fund",
  22. },
  23. },
  24. {
  25. path: "/preview",
  26. component: () => import("./view-preview/index"),
  27. },
  28. ];
  29. const router = createRouter({
  30. history: createWebHashHistory(),
  31. routes,
  32. });
  33. router.beforeEach((to, from, next) => {
  34. if (to.meta.title) {
  35. document.title = to.meta.title as string;
  36. }
  37. next();
  38. });
  39. export default router;