错误点:格式问题,或者命名问题
报错 TypeError: Cannot read properties of undefined (reading ‘forEach’)
import { createRouter, createWebHashHistory } from 'vue-router' // 引入路由
// 是routes 不死routers 否则报错 TypeError: Cannot read properties of undefined (reading 'forEach')
const routes = [
{
path: "/", // 路径
component: () => import("../views/Main.vue"), // 路径必须输入完全带后缀vue
children: [
{
path: "/",
name: "home",
component: () => import("../views/home/Home.vue"),
}
]
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
});
//导出
export default router;