首页 > 解决方案 > 将 allvalues 和 formData 中的值放入单个数组中反应 js

问题描述

我正在尝试将 allvalues 和 formData 中的值传递到单个数组中,并通过 react axios 传递它

constructor(props) {
    super(props);
   
    this.state = {
    allValues: {
        name: "",
        class: "",
        school: "",
       
      },
 files: {
        car: null,
        bus: null,
        scooter: null,
      },
};

 let formData = new FormData();
  formData.append("antenatalChart", this.state.files.car);
axios.post("url",
        formData, //appand formdata and allValues

 {
          headers: {
            Authorization: `token ` + localStorage.getItem("token"),
            "Content-type": "multipart/form-data",
          },
        }
      )
      .then((res) => {
        console.log(`Success` + res.data);
      })

我正在尝试将 allvalues 和 formData 中的值传递到单个数组中并通过反应传递

标签: reactjs

解决方案


看看这里。这将帮助您了解如何处理表单中的多个输入。


推荐阅读