简体   繁体   English

使用来自反应路由器 dom 的 LINK 时外部链接不起作用

[英]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.

相关问题 使用 react-router-dom 从 React 应用程序重定向到外部链接 - Redirect to external link from React app using react-router-dom 在 React 路由器 Dom 中使用 NavLink 进行外部链接路由时,本地主机添加到前缀中 - local host getting added in prefix, when using NavLink in React router Dom for external link routing 使用反应路由器的链接编码 Uri 不工作 - Encoding Uri using Link of react router dom not working 在firefox中react-router-dom的链接不起作用 - Link of react-router-dom is not working in firefox 使用 react-router--dom 时如何将道具从父母传递给孙子<link> ? - How to pass props from from parent to grand child when using react-router--dom <Link>? 使用 react-router-dom 中的“Link”时,为什么“无法在“历史”上执行“pushState”? - Why `Failed to execute 'pushState' on 'History'` when using `Link` from react-router-dom? 当使用标签或来自React Router Dom的链接时,Image会继续下载 - When using the a tag or Link from react router dom, Image keeps downloading 当链接在三个 div 内时,React-Router-Dom 的链接不起作用 - Link of React-Router-Dom not working when Link is inside three divs 将 react-router-dom 的链接传递到外部库 - Passing react-router-dom's Link into external library 反应路由器链接不工作 - React Router Link is not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM