如何在新标签中打开惯性链接?
是否有一种方法可以在新选项卡中打开惯性链接
,例如and> Anchor
标签:
<a target="_blank" rel="noopener noreferrer"></a>
这不起作用:
<Link :href="..." target="_blank">
Is there a way to open an inertia link
in a new tab like it's possible in anchor
tags:
<a target="_blank" rel="noopener noreferrer"></a>
This doesn't work:
<Link :href="..." target="_blank">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不认为这是可能的 - 因此,标准的锚标签是必经之路。
这是因为如果将在新选项卡中打开链接,则惯性不需要真正涉及,因为它不必拦截单击并执行自己的服务器请求。
惯性开发人员在此GitHub问题中确认: https://github.com/inertiajs/inertiajs/inertia/issues/Intia/issues/Issues/Issues/Issues /1096
I don't believe this is possible - so a standard anchor tag is the way to go.
This is because Inertia doesn't really need to be involved if a link will be opening in a new tab, since it doesn't have to intercept the click and perform its own server request.
Confirmed by Inertia's developer in this github issue: https://github.com/inertiajs/inertia/issues/1096
这里似乎有同样的问题
但这是很久以前的
我不确定您现在正在使用哪个依赖项
与问题兼容
但是您可以查看是否对您有帮助
react-router open-router open link in New Tab
Seems to have the same problem here
But it was a long time ago
I'm not sure which dependency version you're using now
is compatible with the issue
But you can see if that helps you
React-Router open Link in new tab
尝试以下
JavaScript:
在组件中:
Try the following
Javascript:
In component:
@thomas-lo答案确实帮助我解决了这个问题。我只是对其进行了一些修改,以便我们可以在链接onClick事件上修改URL。
定义此功能:
在组件中:
The @thomas-lo answer really helped me solve the issue. I just modify it a little so we could modify the url on the Link onClick event.
Define this function:
and in the component: