效果与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