实现效果
原:
新:
当我们遇到从首页链接到其他菜单时,需要修改菜单路由的名称,这时可以通过以下步骤修改
1.在router.js添加以下代码
{
path: '/customer/nowdayorder',
component: Layout,
hidden: true,
children: [
{
path: 'index',
component: () => import('@/views/customer/record/index'),
name: 'Record2',
meta: { title: '今日待下单客户', activeMenu: '/index' }
}
]
},
2.在需要调用的页面写以下代码
/** 分配用户 */
function handleRouter(type, num) {
switch (type) {
case 12:
//2.路由发生变化修改页面title
router.beforeEach((to, from, next) => {
// 设置需要变化的路由,否则点击菜单也会改变title
var names = ["shop1", "shop2", "Record2", "vsStock", "sStock", "Record3", "abnormalDcl"]
if (to.meta.title && names.indexOf(to.name) > 0) {
to.meta.title = name + '(' + num + ')';
}
// 必填,否则会出现死循环
next();
});
router.push({
path: "/customer/nowdayorder/index",
query: {type: 1}
});
break;
}
}
3.最终效果如下:
点击按钮,传入参数
本文含有隐藏内容,请 开通VIP 后查看