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;