Vue-Router4.0 报“Cannot read property ‘forEach‘ of undefined”
Vue-Router4.0在创建路由时 报“Cannot read property ‘forEach‘ of undefined”
解决办法
将路由规则名称更改为routes,否则报错
import { createWebHashHistory, createRouter } from 'vue-router'; // 创建路由规定 const routes = [ { path: '/login', name: 'login', component: () => import('../views/login/index.vue'), }, { path: '/report', name: 'report', component: () => import('../views/report/index.vue'), }, ] // 创建路由实例 const router = createRouter({ history: createWebHashHistory(), routes, }) export default router;
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。