Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
Remove query item from router

I'm using replace in vue to add query to the current url . and i assigned undefined if the value is not there.

this.$router.replace({
  name: "admin-frs",
  query: {
    limit: this.pageSize,
    page: this.currentPage,
    sort: this.sortbyapi || undefined,
    language: this.sortbyapiLang || undefined,
  },
})

this makes the query item disappear from the URL when the query data is getting updated which is fine.

it does not remove it from the query object.

any idea if there's a better approach than this?

plus is it possible to get the query as it is from the route? like &limit=10...etc

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If I understand correctly, the OP wishes to manipulate the query object passed to router.replace. It can be done with standard js.

Start by explicitly naming a query variable...

let query = $router.query;

To remove something, use js delete operator. For example, to remove query.limit...

// remove the limit
if (!this.pageSize) delete query.limit;

Or, if you're building that query, don't put limit in in the first place...

let query = {};
if (this.pageSize) query.limit = this.pageSize;
if (this.currentPage) query.page = this.currentPage;
// etc for the other properties
// query will now only have props for those selected above

Do any of these manipulations, then pass to the router referring to the variable...

$router.replace({ name: "admin-frs", query }); 

To restate as a string, there are probably several methods, including many in libraries you might have around, but natively...

let params = [];
for (let key in query)
  params.push(`${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`);
const queryString = params.join("&");
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda