javascript - 如何使用 -react js 编写编辑功能
问题描述
我的问题是当我尝试编辑详细信息时(请参阅编辑详细信息图像)。它应该采用如下图所示的值(id)。但是当我单击编辑按钮时,这些输入字段不显示现有详细信息。我该怎么做.请帮我解决这个错误?
这是我使用后端环回、数据库 mysql 的编辑详细信息表单编码:
<Form onSubmit={this.handleSubmit} layout="inline">
<FormItem {...formItemLayout} label="Title" >
{getFieldDecorator('Title', {
rules: [{ required: true, message: 'Please provide Title!' },{ max: 15, message: 'Title should maximum 15 characters ' },
/* { pattern: '(^[A-Z][a-z]*$)', message: ' Please Start with Uppercase' }*/],
})(
<Select prefix={<Icon type="book" style={{ fontSize: 13 }} />}
showSearch
style={{ width: 65 }}
placeholder="Mr."
optionFilterProp="children"
onChange={this.handleChange}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
>
<Option value="Mr.">Mr.</Option>
<Option value="Ms.">Ms.</Option>
<Option value="Miss.">Miss.</Option>
</Select>
)}
</FormItem>
<FormItem {...formItemLayout} label="Name" >
{getFieldDecorator('Name', {
rules: [{ required: true, message: 'Please provide name!' },{ max: 15, message: 'Name should maximum 15 characters ' },
/* { pattern: '(^[A-Z][a-z]*$)', message: ' Please Start with Uppercase' }*/],
})(
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Name" />
)}
</FormItem>
<FormItem
{...formItemLayout}
label="Relation :"
>
{getFieldDecorator('Relation', {
rules: [{ required: true, message: 'Please provide relation!' }, { max: 200, message: 'Note should be within a 200 characters' }],
})(
<Select prefix={<Icon type="book" style={{ fontSize: 13 }} />}
showSearch
style={{ width: 150 }}
placeholder="Select a Relation"
optionFilterProp="children"
onChange={this.handleChange}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
>
<Option value="Father ">Father</Option>
<Option value="Mother ">Mother</Option>
<Option value="Husband ">Husband</Option>
<Option value="Wife ">Wife</Option>
<Option value="Brother">Brother</Option>
<Option value="Sister">Sister</Option>
<Option value=" Other"> <Input placeholder="Other" style={{ marginLeft:-7,width: 140,height:32 }} type="text"/> </Option>
</Select>
)}
</FormItem>
<FormItem
{...formItemLayout}
label="Contact No :"
>
{getFieldDecorator('Telephone_no', {
rules: [{
required: true, message: 'Please input contact number!',
}, { max: 10, message: 'You can only add 10 numbers' }, { pattern: '^[0-9]\\d{0,9}?%?$', message: 'Should be a number' },{ min: 10, message: 'You can not add less than 10 numbers' } ],
})(
<Input prefix={<Icon type="phone" style={{ fontSize: 13 }} />} placeholder="Contact No" style={{ width: 150 }} />
)}
</FormItem>
<FormItem label="Address:" {...formItemLayout}>
{getFieldDecorator('Address', {
rules: [{ required: true, message: 'Please provide address!' }, { max: 100, message: 'Note should be within a 100 characters' }],
})(
<TextArea prefix={<Icon type="book" style={{ fontSize: 13 }} />} placeholder="Address ...?" style={{ width: 350 ,height:75 ,marginTop: 20 ,marginLeft: 33} } />
)}
</FormItem>
<FormItem >
<Row>
<Button type="primary" icon="check-circle-o" htmlType="submit" style={{ marginLeft: 85,marginTop: 40 }}/>
<Button htmlType="reset" icon="close-circle" style={{ marginLeft:8 ,marginTop: 40}} onClick={this.resetFields} />
<Button htmlType="reset" onClick={this.cancelEdit} icon="close-circle" style={{ marginLeft: 8 }}>Cancel</Button>
</Row>
</FormItem>
</Form>
解决方案
推荐阅读
- javascript - 第三次点击元素后发送道具
- react-native - 为 React Native 选择器设置样式以与文本输入对齐
- visual-studio - 使用 Visual Studio 2017 在单独的 chrome 窗口上打开多个 Web/Api 项目
- json - 如何解决使用 parse 引起的 JSON Injection 漏洞
- javascript - 从文件加载 XML 并解析?
- c# - 从 Web 服务接收 C# 中的数据
- c# - 使用 EF Core 和内存数据库进行单元测试
- jsf - JSF websocket 更新 viewScope
- java - 如何在我的自定义布局(VBox、HBox 等)元素中获取用 fxml 编写的所有子标签
- react-redux - 根据 first 的响应在 redux observables 中对 ajax 请求进行排序,并单独处理错误和调度动作