<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貢獻(xiàn)1788條經(jīng)驗(yàn) 獲得超4個(gè)贊
{list.map((item, index) => { return <li key={index}> <Link to={`/section${index + 1}`}>{item}</Link> </li> })}
因?yàn)槲仪短琢?層<Router>去掉就可以了...
添加回答
舉報(bào)
0/150
提交
取消