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