鍍金池/ 問答/HTML5  網(wǎng)絡(luò)安全  HTML/ react-router4.0 js如何跳轉(zhuǎn),如何地址欄傳遞?key=value

react-router4.0 js如何跳轉(zhuǎn),如何地址欄傳遞?key=value的參數(shù),在新頁(yè)面如何獲取

react-router4.0 js如何跳轉(zhuǎn),如何地址欄傳遞?key=value的參數(shù),在新頁(yè)面如何獲取

回答
編輯回答
未命名

react-router里有個(gè)withRouter,可以給你的組件注入history啊什么相關(guān)路由方法和信息。

import {withRouter} from 'react-router-dom'

class MyComponent extends Component {
    doSth = () => {
        this.props.history.push('/xxx')
    }
}
export default withRouter(MyComponent)
2017年2月4日 22:53
編輯回答
茍活

用的2可以this.props.location.query.key
不知道4有沒有

2017年12月4日 00:17