React-router JSX 写法的问题

跟着demo做的,文件:

const routerConfig = [
    {
        path          : '/',
        component     : Main,
        childrenRoutes: [
            {path: 'about', component: About},
            {path: 'inbox', component: Inbox}
        ]
    },
    {
        path: '*',
        component: Not
    }
];

ReactDOM.render(
    <Router routes={routerConfig} history={browserHistory}/>,
    document.querySelector('#APP')
);

其他一切正常就是到/about和/inbox时会报404.。

阅读 2.2k
1 个回答

代码写错了:

const routerConfig = [
    {
        path          : '/',
        component     : Main,
        childRoutes: [
            {path: 'about', component: About},
            {path: 'inbox', component: Inbox}
        ]
    },
    {
        path: '*',
        component: Not
    }
];

不是childrenRoutes

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题