react 动态添加卡片

 ​
let id = 0;
add = () => {
    const { form } = this.props;
    // can use data-binding to get
    const keys = form.getFieldValue('keys');
    const nextKeys = keys.concat(++id);
    // can use data-binding to set
    // important! notify form to detect changes
    form.setFieldsValue({
      keys: nextKeys,
    });
  }
  const { getFieldDecorator, getFieldValue } = this.props.form;
  
    getFieldDecorator('keys', { initialValue: [] });
    const keys = getFieldValue('keys');
    const formItems = keys.map((k, index) => (
      
{getFieldDecorator(`names[${k}]` )(

Card content

Card content

Card content

)}
));
   
        

进行中的项目

More}>

Card content

Card content

Card content

More}>

Card content

Card content

Card content

More}>

Card content

Card content

Card content

{formItems}

效果如下:

你可能感兴趣的:(react)