Reactjs 如何使用';从DateTimePicker获取所选值;react datetime';

Reactjs 如何使用';从DateTimePicker获取所选值;react datetime';,reactjs,Reactjs,我想从我的DateTimePicker中获取一个选定的值。我看到的不是值,而是[Object] 这是我的约会时间选择器 import React from 'react'; import momentLocaliser from 'react-widgets-moment'; import DateTime from 'react-datetime'; import PropTypes from 'prop-types'; import className

我想从我的DateTimePicker中获取一个选定的值。我看到的不是值,而是[Object]

这是我的约会时间选择器

  import React from 'react';

    import momentLocaliser from 'react-widgets-moment';

    import DateTime from 'react-datetime';

   import PropTypes from 'prop-types';
    import classNames from 'classnames';

  const moment = require('moment');

  moment.locale('es');

  momentLocaliser(moment);


   const handleChange = (e) =>{

      const valueOfInput = moment(e.target.value).format('DD-MM-YYYY HH:mm');

    return valueOfInput;

    }

    const DateTimePickerInput = ({
           label,
           format,
           input,
           width,
           placeholder,
           selected,
           tooltip,
           tooltipPlacement,
           disabled,
          defaultValue,
          inputProps,
           meta: { valid, touched, error},
          //input: { onChange, value, onBlur},
          showTime,
          ...props
           }) => {

          const classes = classNames('form-group', {
           'has-error': (touched && !valid),
            'has-success': (touched && !valid)
         })
       return (
          <div className={classes}>
             <label htmlFor={input.name}>{label}</label> <br />
             <DateTime

            name = {input.name}
            locale='es'
            dateFormat= "DD-MM-YYYY"
            timeFormat= "HH:mm"

          onChange = {(changedVal) => handleChange(changedVal)}

          inputProps={{disabled: true, placeholder: {handleChange}}} //In placeholder is the issue

         />

        {(!valid && touched) &&
             <p className='help-block'>{error}</p>
           }
          </div>
         );
      };

     DateTimePickerInput.propTypes = {
         disabled: PropTypes.bool,
         input: PropTypes.object.isRequired,
         label: PropTypes.string.isRequired,
         meta: PropTypes.object.isRequired,
         placeholder: PropTypes.string,
         tooltip: PropTypes.string,
         tooltipPlacement: PropTypes.string
      }




    export default DateTimePickerInput;
从“React”导入React;
从“react widgets moment”导入momentLocaliser;
从“反应日期时间”导入日期时间;
从“道具类型”导入道具类型;
从“类名称”导入类名称;
恒力矩=要求的(‘力矩’);
地点('es');
力矩定位器(力矩);
常数handleChange=(e)=>{
常量值输入=力矩(即目标值)。格式('DD-MM-YYYY HH:MM');
输入的返回值;
}
常量DateTimePickerInput=({
标签,
格式,
输入,
宽度,
占位符,
挑选出来的,
工具提示,
工具放置,
残废
默认值,
输入道具,
meta:{有效,触碰,错误},
//输入:{onChange,value,onBlur},
表演时间,
…道具
}) => {
常量类=类名('form-group'{
'has error':(触摸&&!有效),
'has success':(触摸&&!有效)
})
返回(
{label}
handleChange(changedVal)} inputProps={{disabled:true,占位符:{handleChange}}}//In占位符是问题所在 /> {(!valid&&toucted)&&

{error}

} ); }; DateTimePickerInput.propTypes={ 禁用:PropTypes.bool, 输入:PropTypes.object.isRequired, 标签:PropTypes.string.isRequired, meta:PropTypes.object.isRequired, 占位符:PropTypes.string, 工具提示:PropTypes.string, tooltipPlacement:PropTypes.string } 导出默认DateTimePickerInput;
我希望从dateTimePicker获取所选的值,但只能看到我看到的[Object]

我现在需要解决

我相信,如果我在声明DateTimePickerInput并分配给占位符onChange时声明onChange-like参数,事情就会改变。但我不确定。我需要任何人告诉我出了什么事

onChange:日期更改时回调触发。如果输入中的日期有效,则回调将所选的力矩对象作为唯一参数接收。如果输入中的日期无效,回调将接收输入值(字符串)

因此,将
时刻(e.target.value)
更改为
时刻(e.toDate())


如果答案不能解决你的问题,请跟随你的问题并询问后续问题。我只是解决了。inputProps={{占位符:!input.value?请输入日期“?input.value,禁用:true}}嗨!我知道这和问题不一样。但是我怎样才能在
时刻获得
e.target.name
const handleChange = (e) =>{
   const valueOfInput = moment(e.toDate()).format('DD-MM-YYYY HH:mm');

   return valueOfInput;
   }

  inputProps={{ placeholder:moment().format('DD-MM-YYYY HH:mm'), disabled: true }}