利用a标签的target属性,把target设置成具体的页面跳转值,如果浏览器已经有标签页的地址是#/companyIndex,则点击上面的链接并不会打开新窗口,是直接进入已经打开的#/companyIndex;如果浏览器中没有地址是#/companyIndex的标签页,则此时target属性的行为表现类似'_blank',会打开一个新的#/companyIndex标签页 ,有两种写法
1.直接在html页面中写死
<a class="product_content1_item_title pointer" target="#/companyIndex" href="#/companyIndex" >中央门户</a>
2.写在js中,通过$router.resolve()获取页面地址,并且还可以自己需要的逻辑
<a class="product_content1_item_title pointer" target="#/companyIndex" id="zhongyang" @click="jumpToEvent('zhongyang','companyIndex')">中央门户</a>
methods:{
jumpToEvent(id,path){
const news = this.$router.resolve(path);
console.log(news.href);
// window.location.href = news.href;// 在当前标签页打开
// window.open(news.href,'_blank')// 打开新标签页
// window.open(news.href)// 打开新标签页
let a = document.getElementById(id);
a.setAttribute("href",news.href);
console.log(a)
}
}