如何从叠加中获取选择值以在响应中显示在页面上

时间:2016-12-22 06:10:08

标签: javascript reactjs react-native react-jsx reactjs-flux

重叠文件:

     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我不能使用普通和方法。

0 个答案:

没有答案