reactjs - 无法以antd输入形式获取输入组内一个输入文本的输入值
问题描述
在 antd 表单中,我有一个输入组,它有两个输入文本字段,并且有一个添加按钮来动态添加字段和删除字段。在提交时,我只收到输入文本的一个输入值。
您可以在以下链接中找到代码
// https://codesandbox.io/s/hopeful-kilby-tkzfh
const keys = getFieldValue("keys");
const formItems = keys.map((k, index) => (
<Form.Item
{...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)}
label={index === 0 ? "Passengers" : ""}
required={false}
key={k}
>
{getFieldDecorator(`passenger${k}`, {
validateTrigger: ["onChange", "onBlur"],
rules: [
{
required: true,
whitespace: true,
message: "Please input passenger's name or delete this field."
}
]
})(
<InputGroup>
<Input
style={{ width: 100, textAlign: "center" }}
placeholder="Minimum"
/>
<Input
style={{
width: 30,
borderLeft: 0,
pointerEvents: "none",
backgroundColor: "#fff"
}}
placeholder="~"
disabled
/>
<Input
style={{ width: 100, textAlign: "center", borderLeft: 0 }}
placeholder="Maximum"
/>
</InputGroup>
)}
{keys.length > 1 ? (
<Icon
className="dynamic-delete-button"
type="minus-circle-o"
onClick={() => this.remove(k)}
/>
) : null}
</Form.Item>```
I need to get both the values of the input texts in the input group.
解决方案
推荐阅读
- reactjs - ReactJS:在道具中使用链接而不是标签
- c# - 追加到富文本框中的多个 RTF 文件
- oracle - 如何在oracle中检查最后连接的用户,时间?
- angularjs - angularJS切换按钮如何获取ng-model值
- angular - 如何删除 PrimeNG 编辑器的选项卡功能
- opencv - 旋转和平移不变性的特征检测器?
- sql - 查询以查找返回多余结果集的重复项
- react-native - ReactNative:使用 react-native-push-notification 库接收通知时,我的应用程序崩溃
- vba - 将 PDFMaker 插件与 Outlook VBA 一起使用
- scenekit - 是否将场景工具包节点附加到 ARAnchor 只是将节点的变换设置为锚点的变换?