Git Product home page Git Product logo

Comments (6)

ouy-o3o avatar ouy-o3o commented on July 19, 2024 1

我不太理解onCalendarChange这个方法的调用时机,我一直无法触发它,以及你想要实现的效果看起来是只能选择开始时间自动设置结束时间为三年后,

 onValuesChange={(params) => {
        const key = Object.keys(params)?.[0];
        if ("validityDate" === key) {
          form.setFieldValue("validityDate", [
            params.validityDate[0],
            moment(params.validityDate[0]).add(3, "years"),
          ]);
        }
      }}

在form上设置这个方法 可以帮到你吗

from ant-design.

ouy-o3o avatar ouy-o3o commented on July 19, 2024
  1. disabled 是会被formItem影响
  2. state的值没有被回显 是因为设置的是defaultValue,受控需要在onValueChange或者useeffect 里依赖state 使用form对{[name]:value}赋值

from ant-design.

BrunaDeLafel avatar BrunaDeLafel commented on July 19, 2024
  1. disabled 是会被formItem影响
  2. state的值没有被回显 是因为设置的是defaultValue,受控需要在onValueChange或者useeffect 里依赖state 使用form对{[name]:value}赋值

貌似在onCalendarChange中使用form.setFieldValue(‘validityDate’, xxx) 也赋值不了, 也是因为form.item 有了initialValue的缘故么

from ant-design.

BrunaDeLafel avatar BrunaDeLafel commented on July 19, 2024
  1. disabled 是会被formItem影响
  2. state的值没有被回显 是因为设置的是defaultValue,受控需要在onValueChange或者useeffect 里依赖state 使用form对{[name]:value}赋值
image 我这么使用也是无效的, 去掉disabled=[false, true]属性就可以

from ant-design.

BrunaDeLafel avatar BrunaDeLafel commented on July 19, 2024

我不太理解onCalendarChange这个方法的调用时机,我一直无法触发它,以及你想要实现的效果看起来是只能选择开始时间自动设置结束时间为三年后,

 onValuesChange={(params) => {
        const key = Object.keys(params)?.[0];
        if ("validityDate" === key) {
          form.setFieldValue("validityDate", [
            params.validityDate[0],
            moment(params.validityDate[0]).add(3, "years"),
          ]);
        }
      }}

在form上设置这个方法 可以帮到你吗
我尝试尝试

from ant-design.

MadCcc avatar MadCcc commented on July 19, 2024

抱歉 4.x 已经过了维护期,不再提供支持了
https://ant-design.antgroup.com/docs/blog/v4-ood-cn

from ant-design.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.