Vue routes forEach is not a function【解决办法】

今天爱分享给大家带来Vue routes forEach is not a function【解决办法】,希望能够帮助到大家。
原因: forEach routes没有发现里面有值
解决:
1.查看import {routes} from ‘./routes’这个路径是否正确
2.routes是一个数组,检查routes是否是一个数组
3.是否已经new了一个router,又再次new一遍?

// main.js
// 路由配置
const RouterConfig = {
  // 使用HTML5的History模式
  mode: 'history',
  routes: Routers
}
// new VueRouter
const router = new VueRouter(RouterConfig)


// router.js
// 在router中又再次new一遍,重复了!!!!
export default new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: home
    }
  ]
})

改为:
// router.js
const routers = [
  {
    path: '/home',
    meta: {
      title: '主页'
    },
    component: (resolve) => require(['../page/home.vue'], resolve)
]
export default routers


原文链接:http://blog.itblood.com/1260.html,转载请注明出处。
0
我的新生活:重置0.96 [神作RPG/AI汉化/动态]
我的新生活:重置0.96 [神作RPG/AI汉化/动态]
刚刚 有人购买 去瞅瞅看

站点公告

显示验证码
没有账号?注册  忘记密码?