Vue 新窗口路由跳转

使用 resolve 进行新窗口跳转

// 只需在 router 文件夹下面的 index 填写路由地址 不需要再使用的地方注册该组件 Print
{
    
    
    path: '/Print',
    name: '测试',
    component: () => import('../views/productionTaskList/Print')
},
// 基础布局
<el-button type="primary" icon="el-icon-view" circle size="mini" plain @click="printerView"></el-button>
// 方法
printerView() {
    
    
    const {
    
    href} = this.$router.resolve({
    
    
    	// 组件路径,不需要引入该组件,只需要在路由创建该组件的路径
        path: '/Print', 
        // query 参数,可以使用 this.$route.query.id 获取参数
        query: {
    
     
            id: 96
        }
    });
    window.open(href, '_blank');//打开新的窗口
}

猜你喜欢

转载自blog.csdn.net/weixin_44640323/article/details/109313452