V4表单列表setFieldValue

V4表单列表setFieldValue

本文介绍了Antd V4表单列表setFieldValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此处输入代码如何动态编辑表单列表中的元素并使用setFieldsValue设置该元素

enter code hereHow can we dynamically edit an element in form list and set that element using setFieldsValue

我得到的一个解决方案是为整个表单列表调用setFieldsValue,但这不公平,会导致性能问题

A solution I got is call setFieldsValue for entire form List but that is not fair, cause performance issue

我有这样的表单结构

users: [
  {
    name: "bob",
    education: [
      {
        qualification: "masters",
        college: "abc",
      },
      {
        qualification: "degree",
        collge: "ijk",
      },
    ],
  },
  {
    name: "alice",
    education: [
      {
        qualification: "ug",
        college: "abc",
      },
      {
        qualification: "higher secondary",
        college: "def",
      },
    ],
  },
];

使用表单列表实现

  • 我想更新用户"alice"的"education [1]"的资格"使用antd v4 setFieldsValue
  • 我有一个解决方案,就是使用getFieldsValue和更改资格",然后更新整个表单值,但是会导致大型应用程序出现性能问题
  • 如何使用setFieldsValue更新表单中的单个字段?
  • 在antd v3中,它是通过在setFeildsValue中提供路径来归档的,例如

  • I want to update 'qualification' of 'education[1]' of user 'alice'using antd v4 setFieldsValue
  • I got a solution that is, take all values using getFieldsValue andchange change 'qualification' and then update entire form value, butit causes some performance issue large applications
  • How to use setFieldsValue to update a single field in form?
  • In antd v3 it is archived by providing path in setFeildsValue like

setFieldsValue({'user.1.education.1.qualification':'something'})

setFieldsValue({ 'user.1.education.1.qualification':'something' })

在此先感谢您提供宝贵的答案

Thanks in advance for your valuable answers

推荐答案

setFields([{name:[data[0].name[0], data[0].name[1], 'component_pm'],value:5}])

这篇关于Antd V4表单列表setFieldValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 21:38