首页 > 解决方案 > 如何在点击时重定向到外部网址?反应

问题描述

我正在使用 react-router 女巫意味着我将路由存储在 app.tsx 文件中。

我有卡片组件需要在点击时重定向到外部 url。

所以我的问题是如何使用外部 url 示例重定向点击卡片组件:www.test.com并向该 url 提供两个查询字符串 a=xxx b=xxx。

标签: reactjstypescriptredirectreact-routerexternal-url

解决方案


那是你需要的吗?

const onClick = () => {
    location.href = 'http://<location>/?a=1';
}

推荐阅读