UNPKG

react-admin-lte

Version:

简单封装的 AdminLTE react 类库,并包含一个编译配置。

35 lines (31 loc) 1.1 kB
import React from 'react'; import InputBase from './InputBase'; import Datetime from 'react-datetime'; export default class InputDatetime extends React.Component { constructor(props, context) { super(props, context); this.onChange = this.onChange.bind(this); console.log("嫑忘记引入 react-datetime 的 css,如果使用中文,需要引入 locale, 参考 https://github.com/YouCanBookMe/react-datetime"); } onChange(value) { if (this.props.onValueChange) { this.props.onValueChange(this.props.name, value.format("YYYY-MM-DD HH:mm:ss")); } } render() { var _this = this; var dateFormat = "YYYY-MM-DD"; var timeFormat = false; if (this.props.withTime) { timeFormat = "HH:mm:ss"; } return ( <InputBase label={this.props.label} name={this.props.name}> <Datetime dateFormat={dateFormat} timeFormat={timeFormat} input={this.props.input} locale={this.props.locale} defaultValue={this.props.defaultValue || new Date} onChange={this.onChange} /> </InputBase> ); } }