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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在react-router4.2中使用js 路由跳轉(zhuǎn)?

如何在react-router4.2中使用js 路由跳轉(zhuǎn)?

收到一只叮咚 2019-05-15 10:42:52
1.頁面有有個按鈕,點擊這個按鈕跳轉(zhuǎn)頁面官方文檔說:使用withRouter解決=====================importReactfrom'react'importPropTypesfrom'prop-types'import{withRouter}from'react-router'classShowTheLocationextendsReact.Component{staticpropTypes={match:PropTypes.object.isRequired,location:PropTypes.object.isRequired,history:PropTypes.object.isRequired}render(){const{match,location,history}=this.propsreturn(Youarenowat{location.pathname})}}constShowTheLocationWithRouter=withRouter(ShowTheLocation)=====================在實際應(yīng)用的時候這段代碼怎么用呢?withRouter是一個高階組件?返回一個ShowTheLocationWithRouter函數(shù)?那這個函數(shù)怎么用到跳轉(zhuǎn)呢?const{match,location,history}=this.props//這行是什么意思呢?使用history.push('/xxx')這樣嗎現(xiàn)在有一個button組件怎么在這個組件上添加事件進行路由跳轉(zhuǎn)呢
查看完整描述

2 回答

?
阿晨1998

TA貢獻2037條經(jīng)驗 獲得超6個贊

拿到history后就可以用代碼進行跳轉(zhuǎn)了,ReactTraining/history:ManagesessionhistorywithJavaScript這是history的倉庫,相關(guān)方法查看這個的文檔
                            
查看完整回答
反對 回復(fù) 2019-05-15
?
牧羊人nacy

TA貢獻1862條經(jīng)驗 獲得超7個贊

//history.js
importcreateHistoryfrom'history/createBrowserHistory'
exportdefaultcreateHistory()
importhistoryfrom'history'
history.push(path)
                            
查看完整回答
反對 回復(fù) 2019-05-15
  • 2 回答
  • 0 關(guān)注
  • 574 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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