第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

react-router 4.0這個(gè)路由怎么配置

react-router 4.0這個(gè)路由怎么配置

海綿寶寶撒 2018-12-03 04:04:42
react-router 4.0這個(gè)路由怎么配置
查看完整描述

1 回答

?
烙印99

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊

react實(shí)現(xiàn)路由可以直接使用react-router。
ReactRouter是由Ryan Florence開發(fā)的應(yīng)用于ReactJS的路由組件,它通過定義ReactJS組件<Routes>及相關(guān)子組件來實(shí)現(xiàn)頁(yè)面路由的映射、參數(shù)的解析和傳遞。
以下是例子:
var ReactRouter = require('react-router');
var Routes = ReactRouter.Routes;
var Route = ReactRouter.Route;

//定義整個(gè)頁(yè)面的路由結(jié)構(gòu)
var routes = (
<Routes location="hash">
<Route path="/" handler={App}>
<Route path="books" name="bookList" handler={Books}/>
<Route path="movies" name="movieList" handler={Movies}/>
</Route>
</Routes>
);
與之前版本不同,在 react-router4 中,渲染<redirect>組件會(huì)直接跳轉(zhuǎn)到目標(biāo)位置。from 屬性僅用于<redirect>包裹著<Switch> 組件中的時(shí)候。
Rendering a <Redirect> will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do
<Redirect to="/somewhere/else"/> // render 該組件發(fā)生跳轉(zhuǎn)

From: A pathname to redirect from. This can only be used to match a location when rendering a <Redirect> inside of a <Switch>. See <Switch children> for more details.

<Switch>
<Redirect from='/old-path' to='/new-path'/>
<Route path='/new-path' component={Place}/>
</Switch>



查看完整回答
反對(duì) 回復(fù) 2018-12-20
  • 1 回答
  • 0 關(guān)注
  • 934 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)