我创建了一个接受数据的猫鼬模式数组类型。我通过复制数组中的对象来在本地添加数据,效果很好……现在我有一个表单字段,我想将数据发布到(猫鼬)。我尝试将数据发布到我的猫鼬,但不知道如何发布>我正在使用反应钩子(useState)来获取值并发送。
const [formData, setFormData] = useState(application)
//这里的应用程序是保存所有表单输入字段的变量,包括team_members。
team_members: [
{
memberEmail: "",
memberPhone: "",
memberFullname: "",
},
{
memberEmail: "",
memberPhone: "",
memberFullname: "",
},
{
memberEmail: "",
memberPhone: "",
memberFullname: "",
},
{
memberEmail: "",
memberPhone: "",
memberFullname: "",
},
{
memberEmail: "",
memberPhone: "",
memberFullname: "",
},
],
下面是输入表单字段以及如何获取值。在 team_members[array] 中输入
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">1. Phone number</label>
<input
value={team_members[0].memberPhone}
onChange={(e) =>
setFormData({
...formData,
current_user_phon: e.target.value,
})
}
type="text"
className="form-control"
pattern="[0-9]{11}"
placeholder="UsersPhoneNumber"
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">1. Email address</label>
<input
value={team_members[0].memberEmail}
onChange={(e) =>
setFormData({
...formData,
urrent_user_email: e.target.value,
})
}
type="email"
className="form-control"
placeholder="UsersEmail"
/>
</div>
</div>
<div className="form-row">
<div className="form-group col-md-12">
<small id="helpBlock" className="form-text text-muted">
Your team members infomation
</small>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputEmail4">2. Fullname</label>
<input
value={team_members[1].memberFullname}
onChange={(e) =>
setFormData({
...formData,
current_user_fullname: e.target.value,
})
}
type="text"
className="form-control"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">2. Phone number</label>
<input
value={team_members[1].memberPhone}
onChange={(e) =>
setFormData({
...formData,
current_user_phone: e.target.value,
})
}
type="text"
className="form-control"
pattern="[0-9]{11}"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">2. Email address</label>
<input
value={team_members[1].memberEmail}
onChange={(e) =>
setFormData({
...formData,
current_user_email: e.target.value,
})
}
type="email"
className="form-control"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputEmail4">3. Fullname</label>
<input
value={team_members[2].memberFullname}
onChange={(e) =>
setFormData({
...formData,
current_user_fullname: e.target.value,
})
}
type="text"
className="form-control"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">3. Phone number</label>
<input
value={team_members[2].memberPhone}
onChange={(e) =>
setFormData({
...formData,
current_user_phone: e.target.value,
})
}
type="text"
className="form-control"
pattern="[0-9]{11}"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">3. Email address</label>
<input
value={team_members[2].memberEmail}
onChange={(e) =>
setFormData({
...formData,
current_user_email: e.target.value,
})
}
type="email"
className="form-control"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputEmail4">4. Fullname</label>
<input
value={team_members[3].memberFullname}
onChange={(e) =>
setFormData({
...formData,
current_user_fullname: e.target.value,
})
}
type="text"
className="form-control"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">4. Phone number</label>
<input
value={team_members[3].memberPhone}
onChange={(e) =>
setFormData({
...formData,
current_user_phone: e.target.value,
})
}
type="text"
className="form-control"
pattern="[0-9]{11}"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">4. Email address</label>
<input
value={team_members[3].memberEmail}
onChange={(e) =>
setFormData({
...formData,
current_user_email: e.target.value,
})
}
type="email"
className="form-control"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputEmail4">5. Fullname</label>
<input
value={team_members[4].memberFullname}
onChange={(e) =>
setFormData({
...formData,
current_user_fullname: e.target.value,
})
}
type="text"
className="form-control"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">5. Phone number</label>
<input
value={team_members[4].memberPhone}
onChange={(e) =>
setFormData({
...formData,
current_user_phone: e.target.value,
})
}
type="text"
className="form-control"
pattern="[0-9]{11}"
placeholder=""
/>
</div>
<div className="form-group col-md-4">
<label htmlFor="inputPassword4">5. Email address</label>
<input
value={team_members[4].memberEmail}
onChange={(e) =>
setFormData({
...formData,
current_user_email: e.target.value,
})
}
type="email"
className="form-control"
placeholder=""
/>
</div>
</div>