gpt4 book ai didi

reactjs - 无法在 react 中打开新选项卡,添加 localhost :3000 on link?

转载 作者:行者123 更新时间:2023-12-03 13:40:07 25 4
gpt4 key购买 nike

我使用了react router doms'链接:

<Link target="_blank" to={"www.mylink.com"} >mylink </Link>

但这会打开新选项卡 http://localhost:3000/www.mylink.com另外,使用 href:

<a href={'www.mylink.com'} target="_blank" > mylink </a>

做同样的事情。打开新选项卡 http://localhost:3000/www.mylink.com如何在新选项卡中仅打开链接?

最佳答案

试试这个

<Link target="_blank" to={"//www.mylink.com"} >mylink </Link>

或者这个

<a href={'//www.mylink.com'} target="_blank" > mylink </a>

更多引用:
Absolute vs relative URLs
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Generic_syntax

关于reactjs - 无法在 react 中打开新选项卡,添加 localhost :3000 on link?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47447441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com