在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  HTML/ react-router 4中,路由無(wú)法直接訪問(wèn),或者跳轉(zhuǎn)

react-router 4中,路由無(wú)法直接訪問(wèn),或者跳轉(zhuǎn)

頁(yè)面結(jié)構(gòu):
RootMap:

            <BrowserRouter history={this.props.history}>
              <Switch>
                    <Route exact path='/' component={Login}/>
                    <Route path='/login' component={Login}/>
                    <Route path='/home' component={Home}/>
                    <Route component={NotFound}/>
              </Switch>
            </BrowserRouter>

Home內(nèi)結(jié)構(gòu):

      <BrowserRouter>
        <div>
          <Head/>
          <Aside/>
          <switch>
            <Route exact path='/home' component={Container}/>
            <Route path='/home/dashboards' component={Container}/>
            <Route path='/home/setedge' component={SetEdge}/>
            <Route path='/home/controls' component={Controls}/>
          </switch>
        </div>
      </BrowserRouter>
      

SetEdge內(nèi)結(jié)構(gòu):

      <BrowserRouter>
        <Switch>
            <Route exact path='/home/setedge' component={SetIot}/>
            <Route path='/home/setedge/setiot' component={SetIot}/>
            <Route path='/home/setedge/setdevice' component={SetDevice}/>
          </Switch>
      </BrowserRouter>
      
      

頁(yè)面結(jié)構(gòu)如上,現(xiàn)在我能進(jìn)入/home和/login,但是就是不能直接進(jìn)入/home/setedge,子路由的所有路由全都不能進(jìn)去,但是如果先進(jìn)/home,再點(diǎn)擊菜單中的跳轉(zhuǎn),就能進(jìn)入/home/setedge

而且我現(xiàn)在如果在/home/setedge/setiot下,點(diǎn)擊返回按鈕,觸發(fā),this.props.history.push('/home/setedge');瀏覽器中路由變化了,但是頁(yè)面回不去。沒(méi)效果

問(wèn)題一,我改怎么寫(xiě)路由,才能我隨意輸入一個(gè)路由就能進(jìn)去,不用一層一層的進(jìn)去,先進(jìn)/home,再點(diǎn)擊菜單中的跳轉(zhuǎn),進(jìn)入/home/setedge,而是直接瀏覽器路由填寫(xiě)/home/setedge進(jìn)入。

問(wèn)題二,我該怎么設(shè)置頁(yè)面跳轉(zhuǎn),才能讓路由生效

回答
編輯回答
陌南塵

只保留最外層的一個(gè) BrowserRouter ,你再試試

2018年8月31日 06:04
編輯回答
詆毀你

我也遇到了 樓主解決了嗎 直接訪問(wèn)不行 只能通過(guò)連接點(diǎn)擊,而且點(diǎn)擊時(shí)明明url已經(jīng)改變了

2017年11月9日 17:23
編輯回答
薄荷糖

我也遇到了同樣的問(wèn)題,請(qǐng)問(wèn)解決方案是什么?

2018年5月3日 03:52