vue 打开重复页签

文章描述了一种在Vue应用中配置产品详情页面的方法,通过router/index.js设置动态路由,tab.js中管理页签,main.js中挂载openPage方法,最后在需要的地方调用来实现页面跳转,其中用产品名称替换页面title。
摘要由CSDN通过智能技术生成

先上图
在这里插入图片描述
这两个红色框线实际都是产品详情页面,用产品名称替代了页面的title

1、首先在router/index.js配置路由

{
    path: '/productDetail',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'productDetail/:productId(\\d+)', //必须该种方法传递参数
        component: () => import('@/views/product/productKanBan/detail'),
        name: 'productDetail',
        meta: { title: '产品详情' }
      }
    ]
  },

2、创建tab.js 文件,添加页签方法

import store from '@/store'
import router from '@/router';
  // 添加tab页签
  //title 页签显示名称
  //url 跳转路由
export function  openPage(title, url) {
  var obj = {path: url, meta: {title: title}}
  store.dispatch('tagsView/addView', obj);
  return router.push(url);
}

3、main.js 中挂载方法

import { openPage } from "@/utils/tab";
Vue.prototype.openPage = openPage

4、在需要位置调用方法

 this.openPage(row.name,'/productDetail/productDetail/'+row.id)
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值