<ul className="nav">
<li>
<Link to="/section1">test1</Link>
</li>
<li>
<Link to="/section2">test2</Link>
</li>
<li>
<Link to="/section3">test3</Link>
</li>
//上边直接写正常
////////////////////////////////////////
//下边就不行,地址可以切换,组件出不来,也切换不了 {list.map((item, index) => {
return <li key={index}> <Router>
<Link to={`/section${index + 1}`}>{item}</Link>
</Router>
</li>
})}</ul>{this.props.children}<Switch>
<Route path="/section1" component={Section1}/>1 <Route path="/section2" component={Section2}/>2 <Route path="/section3" component={Section3}/>3</Switch>
1 回答
尚方宝剑之说
TA贡献1788条经验 获得超4个赞
{list.map((item, index) => { return <li key={index}> <Link to={`/section${index + 1}`}>{item}</Link> </li> })}
因为我嵌套了2层<Router>去掉就可以了...
添加回答
举报
0/150
提交
取消