从搜索React js获取参数

时间:2020-07-28 14:14:56

标签: reactjs react-router

如何从

获取参数
props.location.search

我尝试过的地方

const { propKey, propEid } =  new URLSearchParams(props.location.search);

但是propKeypropEidconsole.log中未显示

我的网址是这样的:

{{baseurl}} / verify-email?key = a6d16a22a82f16c96ee7d2f95c45c9bc&eid = c2Frc2hpMTFAZ21haWwuY29t

1 个答案:

答案 0 :(得分:1)

const params = new URLSearchParams(props.location.search);
const key = params.get('key'); // a6d16a22a82f16c96ee7d2f95c45c9bc&eid=c2Frc2hpMTFAZ21haWwuY29t