Vue路由的页面跳转打开新页面


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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM