this.props.match

this.props.match中包含的是url信息其中this

  • params字段能夠獲取路由參數。

路由爲:url

{ path: "/FriendDetail/ :id/ :index", name: "FriendDetail", component: FriendDetail }
這樣能夠根據 idindex的不一樣獲取不一樣的數據,進行渲染。
 
獲取方法:
let id = this.props.match.params.id;
效果以下:
  •  history包含了組件能夠使用的各類路由系統的方法,經常使用的有 pushreplace,二者都是跳轉頁面,可是 replace 不會引發頁面的刷新,僅僅是改變 url。

使用方法:spa

this.props.history.push('/download'); // 跳轉到「/download」頁面
相關文章
相關標籤/搜索