如何在TypeScript中使用router.navigate打开新选项卡 [英] How to open a new tab with router.navigate in TypeScript

查看:576
本文介绍了如何在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为true时)

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屋!

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