【发布时间】:2017-04-14 10:43:16
【问题描述】:
我正在尝试使用嵌套路由,但它给了我以下错误:
这是我的路线代码。当我尝试为制造商使用嵌套路由时出现错误。
import React from 'react';
import {Router, IndexRoute, Route, hashHistory} from 'react-router';
import {
App,
Home,
ManufacturerDetails,
ManufacturerList,
} from 'containers';
export default () => {
return (
<Router history={hashHistory}>
<Route path="/" name="Home" component={App} >
<IndexRoute component={Home}/>
<Route name="Manufacturers" path="Manufacturers" component={ManufacturerList}>
<Route name="Manufacturer Details" path="/:manufacturer" component={ManufacturerDetails} />
</Route>
</Route>
</Router>
);
};
【问题讨论】:
-
我认为是因为缺少
path="/"的结束路由标记</Route> -
对不起,这里只是复制粘贴错误。关闭路线在文件中。
-
哦,我明白了,我没有深入研究细节,但根据我的经验,两条路径应该放在同一级别。
path="Manufacturers"和path="Manufacturers/:manufacturer",即他们是兄弟姐妹。 -
“/ABB”是否适用于这条路线?
-
是的,如果我把它们放在同一水平线上。它工作正常。
标签: reactjs react-router nested-routes