Reactjs 在react路由器中传递搜索并访问它
在从一个页面导航到另一个页面时,我尝试在搜索中传递两个值。 这是我使用的代码Reactjs 在react路由器中传递搜索并访问它,reactjs,react-router,Reactjs,React Router,在从一个页面导航到另一个页面时,我尝试在搜索中传递两个值。 这是我使用的代码 this.props.history.push({ 路径名:'/topics', 搜索:'?lessonPlanId='+lessonPlanId+'?chapterId='+data.\u id }); 现在我尝试使用 let qs=queryString.parse(this.props.location.search); console.log('qs is',qs); this.lessonPlanId=qs
this.props.history.push({
路径名:'/topics',
搜索:'?lessonPlanId='+lessonPlanId+'?chapterId='+data.\u id
});
现在我尝试使用
let qs=queryString.parse(this.props.location.search);
console.log('qs is',qs);
this.lessonPlanId=qs.id;
我把qs作为一个对象
{lessonPlanId:“5b72dc8195a30e11a11a8ed1?章节ID=5b72dfa995a30e11a11a8ed3”}
我想从中获取lessonPlanId和chapterId。我怎么才能做到这一点,因为我做不到。lessonPlanId和chapterId
是否有更好的传递方法,以便我可以在我的对象中使用lessonPlanId和chapterId?此解决方案将非常受欢迎您需要使用&来分离查询参数。改变
search:'?lessonPlanId='+lessonPlanId+'?chapterId='+data.\u id
到
搜索:'?lessonPlanId='+lessonPlanId+'&chapterId='+data.\u id
是,使用&
而不是?
获取其他参数。的用法会更好。很乐意提供帮助,欢迎使用Stack Overflow。如果此答案或任何其他答案解决了您的问题,请将其标记为已接受