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

183
Vistas
Vue Js : form-data Event

Hello there #Vue.js2 I'm encountering a problem on creating a function called in a form submit event This function needs to take 2 parameters : EVENT and ID My problem now is when I call this function i can't specify the event param without having error so my formdata and my id will be undefined in my logs. Is there any better way to handle my form ?

 updatePost(event, id) { 
  const postId = id;
  const updatedPost = new FormData(event.target); // Any way to not use event param to save this ? 
  console.log(updatedPost, postId);
},
 // Call in my Template but : 
 <form @submit.prevent="updatePost(post.id)">

ps : form composed by 2 inputs type text and 1 input type file.Vue.js screenShot

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

0

The original event is available as $event inside the v-on: handler.

Docs: Methods in Inline Handlers

Sometimes we also need to access the original DOM event in an inline statement handler. You can pass it into a method using the special $event variable

So this should work:

 <form @submit.prevent="updatePost($event, post.id)">
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