vue路由导航守卫实现进入页面后一直携带多个参数

此处携带三个参数
id.
hallid.
jobId.

const router = new Router({
  mode: 'hash',
  routes
})

router.beforeEach((to, from, next) => {
  if (to.query.id && to.query.hallid && to.query.jobId) {
    next();
    return;
  };
  if (from.query.id) {
    let toQuery = JSON.parse(JSON.stringify(to.query));
    toQuery.id = from.query.id;
    toQuery.hallid = from.query.hallid;
    toQuery.jobId = from.query.jobId;
    next({
      path: to.path,
      query: toQuery
    })
  } else {
    next();
  }
})
export default router


你可能感兴趣的:(Vue,vue_实例)