效果與a標簽的target=_blank是一樣的,只不過不用點擊,直接打開
1、在router.js里新加一個頁面路由
{
path: '/helloWorld',
name: 'HelloWorld',
component: () => import('../components/HelloWorld.vue'),
meta: {
title: '預覽文件',
hideInMenu: true
}
}
2、在需要跳轉的邏輯方法里加,這里必須用query,否則參數獲取不到,
methods: {
pageLink(){
console.log(123)
const { href } = this.$router.resolve({
path: `/helloWorld`,
query:{url:'../assets/logo.png'}
});
window.open(href, '_blank', console.log(href));
}
}
3、跳轉頁獲取參數:let url=this.$route.query.url;
轉自:https://www.jianshu.com/p/dd1cca9dbcb3
