关于这个报错 ,
在这里插入图片描述
是因为我从vue项目中转到react项目中 配置路由表时使用的懒加载搞的鬼
我按照vue的懒加载去配置react直接爆了这个错 下面先做个对比 ,然后将配置表改成第二段代码的样子配置 解决!

//vue中
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode:'history',
  routes: [
    {
      path: '/index',
      name: 'index',
      component: ()=> import('@/views/index'),
      children:[
        {
          path:"/index/home",
          component:()=>import('@/views/index/home'),
         
        },{
          path:"/index/type",
          component:()=>import('@/views/index/type'),
        
        },{
          path:"/index/car",
          component:()=>import('@/views/index/car'),
       
        },{
          path:"/index/mine",
          component:()=>import('@/views/index/mine'),
     
        }
      ]
    },{
      path:"/",
      redirect:"/index"
    }
  ]
})
//react中
import Loadable from 'react-loadable'
import React from 'react'
function Loading(){
    return <div>loading...</div>
}
const Index=Loadable({
    loading:Loading,
    loader:()=>import('view/home')
})
const Home=Loadable({
    loading:Loading,
    loader:()=>import('view/home/home')
})
const Order=Loadable({
    loading:Loading,
    loader:()=>import('view/home/order')
})
const Goods=Loadable({
    loading:Loading,
    loader:()=>import('view/home/goods')
})
const Login=Loadable({
    loading:Loading,
    loader:()=>import('view//login')
})
export default [
    {
        path:'/index',
        component:Index,
        children:[
            {
                path:'/home/home',
                component:Home
            },
            {
                path:'/home/goods',
                component:Goods
            },
            {
                path:'/home/order',
                component:Order
            }
        ]
    },
    {
        path:'/login',
        component:Login
    },
    {
        path:'/',
        redirect:'/index'
    }
]
Logo

前往低代码交流专区

更多推荐