提问人:Daniel Claire 提问时间:11/8/2023 最后编辑:Daniel Claire 更新时间:11/8/2023 访问量:20
如何避免显示输入文本框,以便始终在“提交”时发送预定值
How to avoid showing an input text box so that a predetermined value is always sent on 'submit'
问:
我在 react 中有一个与交易日期相对应的输入文本框。输入必须始终为“null”,以便 Java 后端可以创建日期。有没有办法完全消除这个输入框,并在按下提交按钮时以某种方式始终发送值“null”?这是前端代码。
<form onSubmit={(e) => onSubmit(e)}>
<div className="mb-3">
<label htmlFor="PurchDate" className="form-label">
Purchase Date
</label>
<input
type={"text"}
className="form-control"
placeholder="Enter purchase date"
name="purchDate"
value={newProvisioner.purchDate}
onChange={(e)=>onInputChange(e)}
/>
</div>
<button type="submit" className="btn btn-outline-primary" >Submit</button>
<form onSubmit={(e) => onSubmit(e)}>
然后发送到这个
const onInputChange=(e)=>{
setNewProvisioner({...newProvisioner,[e.target.name]: e.target.value});
};
最后到这里
const onSubmit= async(e)=>{
e.preventDefault();
const prov1 = await axios.post(`http://localhost:8080/country/${countId1}/product/${prodId1}`, newProvisioner);
const provData1 = prov1.data;
navigate(`/confirmarbitrage/${provData1.id}`);
}
我给出的代码是简化的,但下图是我看到的,需要修复
答: 暂无答案
评论