Javascript 在反应窗体中使用自定义反应组件
我想使用组件作为表单控件():Javascript 在反应窗体中使用自定义反应组件,javascript,forms,reactjs,react-bootstrap,Javascript,Forms,Reactjs,React Bootstrap,我想使用组件作为表单控件(): 从“反应引导滑块”导入反应引导滑块; 以下是原始代码,它使用类型为number的常规表单输入进行价格计算: import Form from 'react-router-form'; import {FormControl, FormGroup, ControlLabel, Button } from 'react-bootstrap'; render() { return ( <div> <Form me
从“反应引导滑块”导入反应引导滑块;
以下是原始代码,它使用类型为number的常规表单输入进行价格计算:
import Form from 'react-router-form';
import {FormControl, FormGroup, ControlLabel, Button } from 'react-bootstrap';
render() {
return (
<div>
<Form method="POST" to="/create-offer" dataKey="offer">
<FormGroup controlId="formControlsPrice">
<ControlLabel>Price</ControlLabel>
<FormControl
type="number"
placeholder="Enter price"
defaultValue={this.state.offer.price}
/>
</FormGroup>
<p>
<Button type="submit">Submit</Button>
</p>
</Form>
);
}
从“反应路由器表单”导入表单;
从'react bootstrap'导入{FormControl,FormGroup,ControlLabel,Button};
render(){
返回(
价格
提交
);
}
我想用滑块替换标准窗体控件。
当我用
替换
组件时,价格属性没有添加到offer对象中
任何帮助都将不胜感激。您在控制台中看到任何错误吗?不,评论中没有错误您在文件中导入了
ReactBootstrapSlider
组件是否state.offer.price
存在(在两个文件中)?您在控制台中看到任何错误吗?否,评论中没有错误您在文件中导入的ReactBootstrapSlider
组件是否存在state.offer.price
存在(在两个文件中)?
import Form from 'react-router-form';
import {FormControl, FormGroup, ControlLabel, Button } from 'react-bootstrap';
render() {
return (
<div>
<Form method="POST" to="/create-offer" dataKey="offer">
<FormGroup controlId="formControlsPrice">
<ControlLabel>Price</ControlLabel>
<FormControl
type="number"
placeholder="Enter price"
defaultValue={this.state.offer.price}
/>
</FormGroup>
<p>
<Button type="submit">Submit</Button>
</p>
</Form>
);
}