在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):lanjingling0510/react-mobile-datepicker开源软件地址(OpenSource Url):https://github.com/lanjingling0510/react-mobile-datepicker开源编程语言(OpenSource Language):JavaScript 89.3%开源软件介绍(OpenSource Introduction):react-mobile-datepickera lightweight react date picker for mobile, Not more than 4k react-mobile-datepicker provides a component that can set year, month, day, hour, minute and second by sliding up or down. Features
Themedefaultdarkiosandroidandroid-darkCustom date unitset {
'year': {
format: 'YYYY',
caption: 'Year',
step: 1,
},
'month': {
format: 'MM',
caption: 'Mon',
step: 1,
},
'date': {
format: 'DD',
caption: 'Day',
step: 1,
},
'hour': {
format: 'hh',
caption: 'Hour',
step: 1,
},
'minute': {
format: 'mm',
caption: 'Min',
step: 1,
},
'second': {
format: 'hh',
caption: 'Sec',
step: 1,
},
} set {
'hour': {
format: 'hh',
caption: 'Hour',
step: 1,
},
'minute': {
format: 'mm',
caption: 'Min',
step: 1,
},
'second': {
format: 'hh',
caption: 'Sec',
step: 1,
},
} customize the content mapping shown in the month. const monthMap = {
'1': 'Jan',
'2': 'Feb',
'3': 'Mar',
'4': 'Apr',
'5': 'May',
'6': 'Jun',
'7': 'Jul',
'8': 'Aug',
'9': 'Sep',
'10': 'Oct',
'11': 'Nov',
'12': 'Dec',
};
const dateConfig = {
'year': {
format: 'YYYY',
caption: 'Year',
step: 1,
},
'month': {
format: value => monthMap[value.getMonth() + 1],
caption: 'Mon',
step: 1,
},
'date': {
format: 'DD',
caption: 'Day',
step: 1,
},
};
<DatePicker
dateConfig={dateConfig}
/> set const dateConfig = {
'hour': {
format: 'hh',
caption: 'Hour',
step: 1,
},
'minute': {
format: 'mm',
caption: 'Min',
step: 1,
},
'second': {
format: 'hh',
caption: 'Sec',
step: 1,
},
}
<DatePicker
showCaption={true}
dateConfig={dateConfig}
/> Getting StartedInstallUsing npm:
Import what you needThe following guide assumes you have some sort of ES2015 build set up using babel and/or webpack/browserify/gulp/grunt/etc. // Using an ES6 transpiler like Babel
import React from 'react';
import ReactDOM from 'react-dom';
import DatePicker from 'react-mobile-datepicker'; Usage Exampleclass App extends React.Component {
state = {
time: new Date(),
isOpen: false,
}
handleClick = () => {
this.setState({ isOpen: true });
}
handleCancel = () => {
this.setState({ isOpen: false });
}
handleSelect = (time) => {
this.setState({ time, isOpen: false });
}
render() {
return (
<div className="App">
<a
className="select-btn"
onClick={this.handleClick}>
select time
</a>
<DatePicker
value={this.state.time}
isOpen={this.state.isOpen}
onSelect={this.handleSelect}
onCancel={this.handleCancel} />
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('react-box')); PropTypes
DateConfigall default date configuration information, as follows
{
'year': {
format: 'YYYY',
caption: 'Year',
step: 1,
},
'month': {
format: 'M',
caption: 'Mon',
step: 1,
},
'date': {
format: 'D',
caption: 'Day',
step: 1,
},
'hour': {
format: 'hh',
caption: 'Hour',
step: 1,
},
'minute': {
format: 'mm',
caption: 'Min',
step: 1,
},
'second': {
format: 'hh',
caption: 'Sec',
step: 1,
},
} ChangelogHow to ContributeAnyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a new issues or feature request, participate in discussions, upvote or downvote the issues you like or dislike. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论