list.js

importReact, { Component } from‘react’ import { Link } from‘react-router-dom’ classListextendsComponent { render() { return ( <div> <p><Linkto=“/detail/1”>测试文章1</Link></p> <p><Linkto=“/detail/2”>测试文章2</Link></p> <p><Linkto=“/home?title=来自于list”>测试文章3</Link></p> </div> ) } } exportdefaultList

home.js

importReact, { Component } from‘react’ importqsfrom‘qs’ //需要安装 classHomeextendsComponent { render(props) { // console.log(this.props.location.search) console.log(qs.parse(this.props.location.search, { ignoreQueryPrefix:true })) return ( <div>Home 首页内容 {qs.parse(this.props.location.search, { ignoreQueryPrefix:true }).title}</div> ) } } exportdefaultHome

查询参数传参 - 图1