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;
}
复制代码
相关文章
相关标签/搜索