DEV Community

BC
BC

Posted on

Vue3: setup router for NotFound page

Steps

1, Create your own "NotFound.vue" page

2, Add code to main.ts:

const routes = [
  {
    path: "/",
    name: "home",
    component: Home,
  },
  // ... other paths ...
  {
    path: "/:pathMatch(.*)*",
    name: "not-found",
    component: () => import("@/pages/NotFound.vue"),
  },
]
Enter fullscreen mode Exit fullscreen mode

3, Config Nginx:

location / {
    try_files $uri $uri/ /index.html;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)