@9softstudio/react-monthpicker 中文文档教程

发布于 6年前 浏览 26 项目主页 更新于 3年前

React Month Picker

Demo

React 月份选择器

Usage

export default class App extends Component {
    constructor(props) {
        super(props);
    }

    handleSelect = (month, year) => {
        console.log(month, year);
    }

    render() {
        return (
            <MonthPicker onSelect={this.handleSelect} />
        );
    }
}

Props

propTypes = {
    open: PropTypes.bool,
    minMonth: PropTypes.number,
    minYear: PropTypes.number,
    maxMonth: PropTypes.number,
    maxYear: PropTypes.number,
    monthNames: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
    hasRange: PropTypes.bool,
    selectedDropdownYear: PropTypes.number,
    selectedMonth: PropTypes.number,
    onSelect: PropTypes.func,
    onFormat: PropTypes.func,
    isReadonly: PropTypes.bool,
    iconElement: PropTypes.any,
    enable: PropTypes.bool
}

defaultProps = {
    open: false,
    onSelect: () => { },
    onFormat: (month, year) => {
        return `${month < 10 ? '0' + month : month}/${year}`
    },
    isReadonly: true,
    monthNames: [
        ['Jan', 'Feb', 'Mar'],
        ['Apr', 'May', 'Jun'],
        ['Jul', 'Aug', 'Sep'],
        ['Oct', 'Nov', 'Dec']
    ],
    enable: true
}

License

MIT

React Month Picker

Demo

React Month Picker

Usage

export default class App extends Component {
    constructor(props) {
        super(props);
    }

    handleSelect = (month, year) => {
        console.log(month, year);
    }

    render() {
        return (
            <MonthPicker onSelect={this.handleSelect} />
        );
    }
}

Props

propTypes = {
    open: PropTypes.bool,
    minMonth: PropTypes.number,
    minYear: PropTypes.number,
    maxMonth: PropTypes.number,
    maxYear: PropTypes.number,
    monthNames: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
    hasRange: PropTypes.bool,
    selectedDropdownYear: PropTypes.number,
    selectedMonth: PropTypes.number,
    onSelect: PropTypes.func,
    onFormat: PropTypes.func,
    isReadonly: PropTypes.bool,
    iconElement: PropTypes.any,
    enable: PropTypes.bool
}

defaultProps = {
    open: false,
    onSelect: () => { },
    onFormat: (month, year) => {
        return `${month < 10 ? '0' + month : month}/${year}`
    },
    isReadonly: true,
    monthNames: [
        ['Jan', 'Feb', 'Mar'],
        ['Apr', 'May', 'Jun'],
        ['Jul', 'Aug', 'Sep'],
        ['Oct', 'Nov', 'Dec']
    ],
    enable: true
}

License

MIT

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文