重叠文件:
const option=["a", "b", "c", "d"];
export default class Add extends Component {
constructor (props) {
super(props);
this.state = {options: option};
}
onSelect(event) {
this.setState({selectState: event.value});
}
render () {
const { onClose } = this.props;
const {options, selectState} = this.state;
return (
<Layer onClose={onClose} >
<div >
<Form>
<FormField label="Device Categories (250)">
<Select value={selectState} options={options}
onChange={this.onSelect} />
</FormField>
<div>
<Button type="submit" label="OK" href="#"
onClick={onClose} />
</div>
</Form>
</Box>
</Layer>
);
}
};
主档案:
var Category = React.createClass({
render: function(props) {
const { selectState, devicevalue } = this.props;
return (
<div>
{devicevalue}
</div>
);
}
});
我希望叠加层中的selectState值显示在devicevalue中 问题是,当我选择一个值,并且叠加显示时,在我在叠加层中选择一个值后,叠加层消失,这在reactjs中是正常的。现在因为元素不存在,我怎样才能从中提取一个值?我只想让我的选择获取一个值并将其显示为已选中。 BTW我不能使用普通和方法。