vue 新窗口打開外連接

背景:vue-router 打開外連接 若是使用 a 標籤,會默認加上根路由,致使跳轉失效。那麼如何讓 a 標籤點擊跳轉到新窗口?css

解決方法:html

html 代碼vue

<a class="a-style" @click="linkDownload('https://www.baidu.com')">百度</a>複製代碼

js 代碼vue-router

linkDownload (url) {
      window.open(url,'_blank') // 新窗口打開外連接
    }
複製代碼

css 代碼bash

.a-style {
  color: #0500ee;
  cursor: pointer;
  text-decoration: underline;
}
複製代碼
相關文章
相關標籤/搜索