鍍金池/ 問(wèn)答/HTML5  HTML/ react-router 4.0做登錄頁(yè)遇到的問(wèn)題

react-router 4.0做登錄頁(yè)遇到的問(wèn)題

圖片描述

圖片描述

最近在學(xué)習(xí)react,想做一個(gè)登陸demo,在react-router 4.0官網(wǎng)(http://reacttraining.cn/web/e...)copy 了一個(gè)認(rèn)證的例子,有一個(gè)地方?jīng)]有搞明白,在65行打印出來(lái)的一堆東西,在68行解構(gòu)后,實(shí)際用到的參數(shù)是哪個(gè)?react的component還有這種用法?哪位大神懂的?求指教,謝謝!

回答
編輯回答
壞脾滊

65行的props就是一個(gè)包含locatiobn,history,match的對(duì)象,
68行就是結(jié)構(gòu)將傳遞給了Protected組件,傳遞的就是location,history,match
const Protected = (props) => {

console.log(props);
return <h3>Protected</h3>

};
把Protected組件該成這樣你就明白了

2017年5月9日 03:38