<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>
尚方宝剑之说
相关分类