[英]External link not working when using LINK from react router dom
This is the code i have used for redirection.这是我用于重定向的代码。
It is redirecting to它正在重定向到
http://localhost:3000/something/https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies
instead of代替
https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies
<Link
to={{
pathname:
"https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies"
}}
target="_blank"
>
<Button variant="contained" className="py-1 px-2">
<i className="ri-upload-2-line pe-2"></i> Apply
</Button>
</Link>
I think react-router attempt assuming relative path, if you want absolute link you can use directly tag a
instead of Link
component.我认为 react-router 尝试假设相对路径,如果你想要绝对链接你可以直接使用标记
a
而不是Link
组件。
<a href="https://example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies" target="_blank">
<Button
variant="contained"
className="py-1 px-2">
<i className="ri-upload-2-line pe-2"></i> Apply
</Button>
</a>
Next.js Link
is designed to be used only as a internal routing tool, because it works with next.js router. Next.js
Link
仅用作内部路由工具,因为它与 next.js 路由器一起使用。 For external link use standart anchor tag <a href...
对于外部链接,使用标准锚标记
<a href...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.