背景:vue-router 打開外鏈接 如果使用 a 標簽,會默認加上根路由,導致跳轉失效。那么如何讓 a 標簽點擊跳轉到新窗口?
解決方法:
html 代碼
<a class="a-style" @click="linkDownload('https://www.baidu.com')">百度</a>復制代碼
js 代碼
linkDownload (url) {window.open(url,'_blank') // 新窗口打開外鏈接}
復制代碼
css 代碼
.a-style {color: #0500ee;cursor: pointer;text-decoration: underline;
}
復制代碼