亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

react4怎么嵌套路由啊?我的二級路由沒有顯示,也不報錯是怎么回事?

react4怎么嵌套路由啊?我的二級路由沒有顯示,也不報錯是怎么回事?

Helenr 2019-03-21 22:19:26
下面是首頁路由的配置class RouterMap extends React.Component {    render() {        return (<BrowserRouter><div>            <Switch>            <Route path='/' exact component={Home}/>             <Route path="/users" component={Users}/>            <Route path='/city' component={City}/>            <Route path='/city2' component={City2}/>            <Route path='/result' component={Result}/>            <Route match='match' path='/dashboard' exact component={Dashboard}/>            <Route path='/dashboard/id'  component={Dashboard200}/>            </Switch>        </div></BrowserRouter>)    }}下面是子路由頁面的配置class Dashboard extends React.Component {    componentDidMount(){        //console.log(this.props)    }    render() {        console.log(this.props)        const match=this.props.match        return (<div>            <div>123</div>            <Switch>                <Route path={`${match.url}/2`} component={Dashboard6}/>                <Route path={`${match.url}/3`} component={Dashboard1}/>                <Route path="/2" component={Dashboard1}/>            </Switch>         </div>)    }}
查看完整描述

2 回答

?
藍山帝景

TA貢獻1843條經驗 獲得超7個贊

謝謝啊,已經解決了,主要是不能有exact,


查看完整回答
1 反對 回復 2019-04-10
  • 2 回答
  • 0 關注
  • 3383 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號