我的 FilePond 海报预览代码不起作用,请帮我找出我做错了什么。
我尝试了下面看到的代码的不同变体,但没有运气。
-我尝试启用即时上传(没有用)
import React, { Component, Fragment } from 'react';
import { FilePond, File, registerPlugin } from 'react-filepond';
import FilePondPluginImagePreview from 'filepond-plugin-image-preview';
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css';
import FilePondPluginFilePoster from 'filepond-plugin-file-poster';
import 'filepond-plugin-file-poster/dist/filepond-plugin-file-poster.css';
import 'filepond/dist/filepond.min.css';
registerPlugin(FilePondPluginImagePreview, FilePondPluginFilePoster);
export default class MyFilePond extends Component {
constructor(props) {
super(props);
this.state = {
data: [],
};
}
handleInit() {
console.log('FilePond instance has initialised', this.pond);
}
render() {
return (
<Fragment>
<FilePond
ref={ref => (this.pond = ref)}
allowFilePoster={true}
instantUpload={false}
server={{}}
name="image"
acceptedFileTypes={['image/*']}
oninit={() => this.handleInit()}
>
<File
file={{
name: 'my-file.png',
size: 3001025,
type: 'image/png'
}}
metadata={{poster : 'https://www.pngarts.com/files/3/Spongebob-Squarepants-Transparent.png'}}
source="https://www.pngarts.com/files/3/Spongebob-Squarepants-Transparent.png"
/>
</FilePond>
</Fragment>
);
}
}