Javascript 如何从文本字段中获取值并通过单击按钮进行选择?
我使用react with redux和material ui,我需要从TextField获取订单数据。我有下一个代码:Javascript 如何从文本字段中获取值并通过单击按钮进行选择?,javascript,reactjs,redux,react-redux,material-ui,Javascript,Reactjs,Redux,React Redux,Material Ui,我使用react with redux和material ui,我需要从TextField获取订单数据。我有下一个代码: <Select value={product.color_set[0].title}> { product.color_set.map(item => ( <MenuItem key={item.key} value={item.title}>{item.title}</MenuItem> )) } </Sele
<Select value={product.color_set[0].title}>
{
product.color_set.map(item => (
<MenuItem key={item.key} value={item.title}>{item.title}</MenuItem>
))
}
</Select>
{
product.color\u set.map(项目=>(
{item.title}
))
}
我还有一个带有onClick箭头功能的按钮:
<Button raised color='primary' onClick={() => {add2Cart()}}>
<AddBasketIcon/>Add to cart
</Button>
{add2Cart()}}>
添加到购物车
您可以通过如下方式更改后获得所选值:
<SelectField
onChange={(event, key, payload) => console.log(event, key, payload)}
>
...items...
</SelectField>
console.log(事件、键、负载)}
>
…项目。。。
您可以保存以反映该值
然后在其他任何地方使用它,例如在文本字段或单击按钮后的函数调用中我看不到任何
textField
或onClick
处理程序的实现。最重要的是,我没有看到您试图解决问题的任何努力或代码示例。请检查,因为我不知道如何从Select中删除选定的ManuItem。当我得到数据时,我只是在减速机中得到值。