在反应路由器V3我可以props.location.query.foo
访问它(如果当前位置是?foo=bar
)如何分析中反应路由器V4
在[email protected]
props.location
只有props.location.search
与查询字符串就像?foo=bar&other=thing
一个字符串。
也许我需要手动解析并解构该字符串以找到foo
或other
的值。
截图的console.log(this.props)
: (注意是如何从这里?artist=band
我想从artist
这是值band
得到的值)
为了配合我,我会导入https://www.npmjs.com/package/query-string并手动完成。 –