state
- 刷新不会丢失,不会出现在url中
- 获取:
this.props.location.state
- 传参:
this.props.history.push({ pathname: 'path...' ,state:{ ... } });
query
- 刷新会丢失
- 获取:
this.props.location.query
- 传参:
this.props.history.push({pathname:'path...',query:{ ... });
params
- 会出现在url里
- 获取
this.props.match.params
- 传参:
this.props.history.push({pathname:`/demo/${damo1}/${damo2}`});
//直接把数据拼接到url中;可以用window.location.search获取?后的所有参数。