Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker只选择年份,设置了mode=year,但是无法触发onChange #14017

zhangyanling77 opened this issue Dec 29, 2018 · 3 comments


None yet
4 participants
Copy link

commented Dec 29, 2018

The issue which is not created via will be closed immediately.

注意:不是用 创建的 issue 会被立即关闭。


This comment has been minimized.

Copy link

commented Dec 29, 2018

Hello @zhangyanling77, your issue has been closed because it does not conform to our issue requirements. Please use the Issue Helper to create an issue, thank you!

你好 @zhangyanling77,为了能够进行高效沟通,我们对 issue 有一定的格式要求,你的 issue 因为不符合要求而被自动关闭。你可以通过 issue 助手 来创建 issue 以方便我们定位错误。谢谢配合!


This comment has been minimized.

Copy link

commented Mar 29, 2019

<LocaleProvider locale={zhCN}> { getFieldDecorator(field)( <DatePicker style={ style } placeholder={ placeholder || '请选择年份' } locale={ zhCN } // value={ this.state.time } open={ this.state.yearStartShow } mode='year' format='YYYY' // onChange={ this.handleChange } onOpenChange={ this.handleOpenChange.bind(this,'yearStart') } onPanelChange={ this.handlePanelChange.bind(this,'yearStart') } /> ) } </LocaleProvider>

do like this ,you will fix this bug, use onOpenChange and onPanelChange (maybe you need onFocus)

tks, 一江西流 关于antd 日期组件只选择年份,设置mode=year无法获取value的解决办法



This comment has been minimized.

Copy link

commented Apr 10, 2019

感谢 @Aladingding 的文章,@zhangyanling77 你们可以尝试这样解决问题:

class Demo extends Component {
  hankPicker = null
  hankYearChange = v => {
    // 更新 v
    // 强制关闭补丁
    this.hankPicker.picker.setState({ open: false });
  render() {
    return (
        ref={ref => (this.hankPicker = ref)}
        format="YYYY" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.