vue 路由resolve参数

4,003 阅读1分钟
多个参数传递

编程式导航方式使用this.$router.resolve方法

dofunc () {  

 let routeUrl = this.$router.resolve(

  {

     path: '/abc', 

     query: {id : 22} 

   }) 

    window.open(routeUrl .href, '_blank) 

 }

blank跳转的方式是不支持params传递参数的

需要传递的参数很多,通过query传递参数不现实 

需要传的参数内的唯一标识符通过query传递到新开的页面。

解决方案:

vue 通过 name 和 params 进行调整页面传参刷新参数丢失问题

路由:

`{ `

  path: '/case/filing/detail/:id?/:hideFlow?' //多加 ? 代表这个参数是可选的。

  name: 'CaseFilingDetail', 

  component: () => import('mod@/case/views/filing/detail'), 

 },

组件:

handleInterrogate ({ fdId: id }) {     
 const hideFlow = 'true'      
 goToFlowPage({        
 route: {          
  name: 'ViewDetailSwitches',          
  params: {            
    id,            
    hideFlow,            
    activeName: 'interrogate'         
 }        
},       
 target: '_blank'      
 })    
}