Vue项目给每个路由地址添加参数

Router.beforeEach(()=>{

if (to.query.IP) {
    next();
    return;
  };
  if (from.query.IP) {
    let toQuery = JSON.parse(JSON.stringify(to.query));

    toQuery.abc = from.query.IP;
    next({
      path: to.path,
      query: toQuery
    })
  } else {
    next()
  }

})
只需要在全局的路由守卫中添加上述代码即可实现
原文地址:https://www.cnblogs.com/tw6668/p/12779658.html