如何在 TypeScript 中使用 router.navigate 打开新标签页 [英] How to open a new tab with router.navigate in TypeScript
本文介绍了如何在 TypeScript 中使用 router.navigate 打开新标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下打字稿代码将始终在当前浏览器选项卡中打开
The following typescript code will always open in the current browser tab
navigate($data: menuItem, $event: JQueryEventObject) {
//...
let a = $event.currentTarget as HTMLAnchorElement;
router.navigate(a.href);
}
如何在新标签中打开 router.navigate ?(即 $event.ctrlKey 为真时)
How do I make router.navigate open in a new tab ? (that is when $event.ctrlKey is true)
推荐答案
是的,正如你@Daneille 评论的那样,自从 durandal 的路由器插件(导航 功能)不提供打开新标签的方法.
Yes, as you @Daneille commented, you have to handle by your own way since durandal's router plugin (navigate function) does not provide a way to open a new tab.
所以最好按照你评论的方式处理.
So it is better to handle something as you commented.
if ($event.ctrlKey) {
window.open(url);
}
这篇关于如何在 TypeScript 中使用 router.navigate 打开新标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文