Hello there

 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

推荐答案

原始事件在v-on:处理程序中以$event的形式提供.

doctor :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 100 variable

所以这应该是可行的:

 <form @submit.prevent="updatePost($event, post.id)">

Javascript相关问答推荐

JavaScript代理不适用于打开的窗口对象

使用Apps Script缩短谷歌表中的URL?

为什么在react js中没有调用加载器函数?

Vue Quill css仅应用于我的第一个Quill Editor组件+如何自定义工具栏

添加/删除时React图像上传重新渲染上传的图像

为什么在获取回调内设置状态(不会)会导致无限循环?

在JavaScript中对大型级联数组进行切片的最有效方法?

每次子路由重定向都会调用父加载器函数

按钮未放置在html dis位置

使用续集和下拉栏显示模型属性

如何解决chrome—extension代码中的错误,它会实时覆盖google—meet的面部图像?'

colored颜色 检测JS,平均图像 colored颜色 检测JS

如何为我的astro页面中的相同组件自动创建不同的内容?

如何通过将实例方法的名称传递给具有正确类型的参数的继承方法来调用实例方法?

在forEach循环中获取目标而不是父对象的属性

用于在路径之间移动图像的查询

JavaScript不重定向配置的PATH

在不扭曲纹理的情况下在顶点着色器中旋转UV

Jexl to LowerCase()和Replace()

MongoDB通过数字或字符串过滤列表