React-Router 在新选项卡中打开链接 [英] React-Router open Link in new tab

查看:74
本文介绍了React-Router 在新选项卡中打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让 React Router 在新标签页中打开链接?我试过了,没有用.

Is there a way to get React Router to open a link in new tab? I tried this and it did not work.

<Link to="chart" target="_blank" query={{test: this.props.test}} >Test</Link>

可以通过向链接添加诸如 onClick="foo" 之类的内容来使之变得模糊,就像我上面所说的那样,但会出现控制台错误.

It's possible to fluff it by adding something like onClick="foo" to the Link like what I have above, but there would be a console error.

谢谢.

推荐答案

我认为 Link 组件没有它的道具.

I think Link component does not have the props for it.

您可以通过创建标签并使用导航 mixin 的 makeHref 方法来创建您的 url 的替代方法

You can have alternative way by create a tag and use the makeHref method of Navigation mixin to create your url

<a target='_blank' href={this.makeHref(routeConsts.CHECK_DOMAIN, {},
   { realm: userStore.getState().realms[0].name })}>
        Share this link to your webmaster
</a>

这篇关于React-Router 在新选项卡中打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆