我在试着从网址上拿到钥匙,它什么也没得到,
这是我想要的浏览器网址。
auth/reset-password/finish?key=123我把路线设成这样
path: '/auth/reset-password/finish/:key?'这是主要的组成部分
const key = queryString.parse('key', location.search);如果我做了控制台,它就等于给我空
我在控制台上记录了它给我的位置
pathname: "/auth/reset-password/finish"
search: "?key=Hci5deBRQJSofcD0aVru"
hash: ""
state: undefined
__proto__: Object 发布于 2020-04-07 11:56:15
解决方案所以这是我对问题的答案
const key = queryString.parse(location.search);所以如果我做了控制台日志。console.log('keyssss', key);,它给了我关键的价值,谢谢你一直以来
发布于 2020-04-07 11:29:22
如果您使用的是react路由器,您可以从location对象获得查询:
this.props.location.query.key要获得命名的params,可以使用:
this.props.match.params.key编辑:此解决方案适用于react路由器3及以下。
发布于 2020-04-07 11:30:00
如果您的路径是path:/auth/reset-password/finish/:key?
所以你的路线应该是/auth/reset-password/finish/123
您可以通过this.props.match.params.key访问密钥
在这里,您将从react路由器获得匹配
https://stackoverflow.com/questions/61078853
复制相似问题