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

131
Vistas
Using v-btn to change route only if some condition is met

How can i prevent this button from firing to the that url path??

I'm trying to make a method check based on some logic and then if it doesn't pass I need to prevent this button from doing anything.

Any help would be much appreciated:)

<v-btn
  @click="checkIfCanCreateTO($event)"
  :to="{ name: 'New', params: { selected: selectedItems, readonly: false } }"
 >
  <v-icon small class="mr-2">mdi-account-plus</v-icon>
  Create New with
  {{ selectedItems.length }} item(s)
 </v-btn>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you don't want the button to change route every time it is clicked but do it conditionally, do not use to prop!

Use only @click handler, check your conditions and then use $router.push({ name: 'New', params: { selected: this.selectedItems, readonly: false } }) inside the handler...

about 4 years ago · Juan Pablo Isaza Denunciar

0

Have you tried this?

<v-btn
  @click.prevent="checkIfCanCreateTO($event)"
  :to="{ name: 'New', params: { selected: selectedItems, readonly: false } }"
 >
  <v-icon small class="mr-2">mdi-account-plus</v-icon>
  Create New with
  {{ selectedItems.length }} item(s)
</v-btn>

Supplement to the answer

You can add "prevent events" to the function

checkIfCanCreateTO(event) {
  event.preventDefault();
  // your code
}
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