我已经将FilePond作为Final Form React的子级运行。我正在尝试将插件注册进去,但是似乎没有用。
import React from 'react';
import { Form, Field } from 'react-final-form';
import { FilePond, registerPlugin } from 'react-filepond';
import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type';
registerPlugin(FilePondPluginFileValidateType);
const FileAdapter = ({ input: {value, onChange}, meta: { touched, submitError }, handleInvalidFileServerResponse, parent }) => (
<>
<FilePond
name="file"
allowFileTypeValidation={true}
fileValidateTypeDetectType={ (source, type) => new Promise((resolve, reject) => {
// Do custom type detection here and return with promise
console.log('type');
return resolve(type);
})}
/>
</>
)
class ContactForm extends React.Component {
render() {
return (
<>
<Form
onSubmit={this.onSubmit}
initialValues={{ files: [] }}
render={({ submitError, handleSubmit, submitting, pristine }) => (
<form className="form-contact text-justify" onSubmit={handleSubmit}>
<Field name="files" component={FileAdapter} />
<input tabIndex="5" type="submit" disabled={submitting || pristine} value={submitting ? 'Submitting...' : 'Submit'}/>
</form>
)}
/>
</>
);
}
}
我尝试console.log
,但似乎未返回任何内容。我也试图拒绝诺言,但没有效果。
答案 0 :(得分:1)
您需要定义一个可接受文件类型的列表。如果列表为空,则接受所有文件。
dependencies {
compile "org.springframework:spring-context:" + springVersion
}