vue打开新tab
通过触发隐藏的a标签的click事件打开
<a ref="mytarget" class="hidetarget" href="" target="_blank" rel="noopener noreferrer"></a>
<xx @click.native="openNewTab('http://xxx')"></xx>
openNewTab(url) {
let target = this.$refs.mytarget
target.setAttribute('href', url)
target.click()
},
.hidetarget {
width: 0;
height: 0;
}
另一种打开新窗口,并指定窗口大小(谷歌浏览器测试有效)
openNewWindow(newUrl) { const winW = 1920 const winH = 1080 const leftValue = (window.innerWidth - winW) / 2 const topValue = (window.innerHeight - winH) / 2 window.open( newUrl, '_blank', 'menubar=no,toolbar=no,status=no,scrollbars=yes,titlebar=no,width=' + winW + ',height=' + winH + ',left=' + leftValue + ',top=' + topValue ) }

浙公网安备 33010602011771号