m-calendar icon indicating copy to clipboard operation
m-calendar copied to clipboard

type为range ,defatultValue值在初始化就传入的时候,没有选中

Open allroad88888888 opened this issue 7 years ago • 2 comments

如题

allroad88888888 avatar Dec 20 '18 03:12 allroad88888888

It seems like this is caused because the constructor calls this.selectDate, but when the visibility changes it calls this.shortcutSelect, which sets the values correctly. Is there a reason that this.shortcutSelect is not called in the constructor?

lilbumblebear avatar Jun 11 '19 13:06 lilbumblebear

I hacked a fix by wrapping the mobile calendar like below

import React from "react";
import {Calendar} from 'antd-mobile';

export default class MobileCalendar extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            visible: false,
        };
    }

    componentDidMount(){
        this.setState({
            visible: true
        })
    }

    render() {
        const { ...props } = this.props;
        return (
            <Calendar {...props} visible={this.state.visible}/>
        );
    }
}

lilbumblebear avatar Jun 11 '19 14:06 lilbumblebear