Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

如标题 发现上传有去调用接口 但是没有调用onChange方法 代码如下

getFieldDecorator('keys', { initialValue: [0] });
          const keys = getFieldValue('keys');
          const formItems = keys.map((k, index) => (
            <Row key={k} gutter={24} style={{border: "1px dashed rgba(0,0,0,0.3)", alignItems: 'center', display: 'flex', flexDirection: 'row', marginBottom: 30}}>
              <Col span={6}>
                <Form.Item
                  key={k}
                  style={{margin: 0}}
                >
                  {getFieldDecorator(`pname[${k}]`, {
                    initialValue: pname[k],
                    rules: [{
                      required: true,
                      whitespace: true,
                      message: "请输入产品名称/标题",
                    }],
                  })(
                    <Input placeholder="产品名称/标题"/>
                  )}
                </Form.Item>
              </Col>
              <Col span={16}>
                <Form.Item style={{margin: 0, marginTop: 25}}>
                  {getFieldDecorator(`pres[${k}]`, {
                    initialValue: fileList && fileList[k] && fileList[k].length > 0 ?  fileList[k] : [],
                    rules: [{
                      required: true,
                      message: "请上传资料类型",
                    }],
                  })(
                    <Upload
                      key={"upload" + k}
                      action={upload}
                      fileList={fileList && fileList[k] && fileList[k].length > 0 ?  fileList[k] : []}
                      onChange={(e) => {this.handleChange(e,k)}}
                      listType="picture-card"
                    >
                      {uploadButton}
                    </Upload>
                  )}
                </Form.Item>
              </Col>
              <Col span={2}>
                  {keys.length > 1 ? (
                    <Icon
                      style={{ marginLeft: 8 }}
                      className="dynamic-delete-button"
                      type="minus-circle-o"
                      onClick={() => this.remove(k)}
                    />
                  ) : null}
              </Col>
            </Row>
          ));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

Form.Item下的onChange是自动注入的 你要自定义的话就要把Upload再封一层


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...