在React中,我要销售的每种服务都会重复以下组件。当用户单击按钮时,我要为其创建自定义URL。我正在使用反应路由器dom。这是我的按钮代码
<button
className="w-full block text-white py-4 rounded-sm"
style={{ background: "#48746e" }}
onClick={this.navigateToRoute}
>
Continue booking
</button>
现在,我可以访问构建URL所需的所有数据,但是我不知道如何执行转换以将其带到该路由。谢谢你的提示
答案 0 :(得分:0)
我会在this.navigateToRoute内部呼叫
<Redirect to="/somewhere/else" />
或者如果您需要通过状态:
<Redirect
to={{
pathname: "/login",
search: "?utm=your+face",
state: { referrer: currentLocation }
}}
/>