Reactjs 在React中添加动态自动完成物料UI字段
我目前正在开发ReactJs应用程序,动态添加输入字段时遇到问题。 当涉及到一个简单的输入字段时,一切都正常(甚至添加和删除字段) 物料界面的自动完成字段出现问题。逻辑工作,但在状态的正确位置没有任何寄存器。要么根本没有注册,要么导致应用程序崩溃 这是一个默认输入字段,其函数用于更改状态:Reactjs 在React中添加动态自动完成物料UI字段,reactjs,autocomplete,material-ui,Reactjs,Autocomplete,Material Ui,我目前正在开发ReactJs应用程序,动态添加输入字段时遇到问题。 当涉及到一个简单的输入字段时,一切都正常(甚至添加和删除字段) 物料界面的自动完成字段出现问题。逻辑工作,但在状态的正确位置没有任何寄存器。要么根本没有注册,要么导致应用程序崩溃 这是一个默认输入字段,其函数用于更改状态: <FormControl className="form-item-two"> <InputLabel> Quan
<FormControl className="form-item-two">
<InputLabel>
Quantity
</InputLabel>
<Input
id="order-detail-quantity"
className="input-form"
type="text"
name="productQuantity"
value={item.productQuantity}
onChange={e => handleChange(e, i)}
/>
</FormControl>
const handleChange = (e, index) => {
const {name, value} = e.target;
const list = [...inputList];
list[index][name] = value;
setInputList(list);
}
<FormControl className="form-item-one">
<Autocomplete
className="input-form"
id="product"
options={data}
autoHighlight
onChange={handleProductInputChange}
getOptionLabel={(item) => item.ref}
renderOption={(item) => (
<React.Fragment>
{item.ref} {item.produit}
</React.Fragment>
)}
renderInput={(params) => (
<TextField
{...params}
label="Choose a product"
variant="outlined"
inputProps={{
...params.inputProps,
autoComplete: "new-password", // disable autocomplete and autofill
}}
/>
)}
/>
</FormControl>
const handleProductInputChange = (values, i) => {
// Do something
};
你有什么想法吗
提前谢谢有人能帮我吗?有人能帮我吗?
const [inputList, setInputList] = useState([
{
productDetails: {
productRef: "",
productName: "",
productDimension: "",
productIndicationOne: "",
productIndicationTwo: "",
productIndicationThree: "",
productIndicationFour: "",
productIndicationFive: "",
productIndicationSix: "",
productIndicationSeven: "",
productIndicationEight: "",
productIndicationNine: "",
productIndicationTen: "",
productIndicationEleven: "",
},
productQuantity: 10,
productTotalPrice: 100,
},
]);