react web项目,页面刷新url的参数不消失

1、安装 query-string
npm i -save-dev query-string

2、点击按钮跳转页面:
this.props.history.push({
pathname: '/g6',
search:`?id=${id}&name=${name}`
});

3、g6页面获取参数:
let {id,name} = querystring.parse(this.props.location.search)


墨子鱼
16 声望1 粉丝