// 通过模板路由配置 import { createRouter, createWebHistory } from "vue-router"; // 创建路由器 const routes = [ // 登录路由 { path: "/login", component: () => import("../views/login/index.vue"), name: "login", //命名路由 }, //登录成功后展示数据的路由 { path: "/", component: () => import("../views/home/index.vue"), name: "layout", }, { path: "/404", component: () => import("../views/noFound/index.vue"), name: "any", }, { path:'/:pathMatch(.*)', redirect : '/404', } ]; const router = createRouter({ history: createWebHistory(), routes, // scrollBehavior(){ // return { // left:0, // top:0 // } // } }); export default router
标签:文件,vue,..,index,vue3,path,import,路由 From: https://www.cnblogs.com/yansunda/p/18462211