原文:只有設置了Route路由的組件,才可以通過this.props.match接受到

項目時,我犯了一個錯誤。Header我沒有設置路由,作為工作組件,然后想在Header組件內部根據路由,隱藏Header,但是因為Header沒有用Route包裹,也沒有用withRouter,其內部是接受不到this.prop.match,this.prop.location,this.prop.history, 因為這三個屬性是父組件Route給他們傳遞的,而這時候你的Header只是普通組件 ...

2019-12-29 15:08 0 227 推薦指數:

查看詳情

this.props.match

this.props.match中包含的是url信息其中 params字段可以獲取路由參數。 路由為: { path: "/FriendDetail/ :id/ :index", name: "FriendDetail", component ...

Wed Aug 07 02:13:00 CST 2019 0 437
React 獲取 url 參數 —— this.props.match

在 react 組件的 componentDidMount 方法中打印一下 this.props,在瀏覽器控制台中查看輸出如下: 其中頁面的 url 信息全都包含在 match 字段中,以地址 為例,其中各個參數定義對應如下: 首先打 ...

Thu Oct 12 00:37:00 CST 2017 0 44490
centos設置路由route

一. route命令 1) 查看:route -n 2)添加: route add [-net|-host] target [netmask Nm] [gw Gw] [[dev ...

Wed Jan 30 19:09:00 CST 2019 0 8647
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM