温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - How do I set up multiple FilePond file input elements on the same page?
filepond

其他 - 如何在同一页面上设置多个FilePond文件输入元素?

发布于 2020-12-28 21:56:53

每当我尝试在同一网页上创建多个Filepond输入时,只有第一个输入具有样式,并且可以作为FilePond网站上的示例完美地工作,而其他输入则不起作用。请尽我所能,但仍然没有得到帮助,请提供帮助。 我的意思是ScreenShot

查看更多

提问者
Klemz Junior
被浏览
0
Rik 2020-06-28 22:06

看起来屏幕快照中的字段尚未初始化,您需要定位要转换为FilePond实例的每个字段。

有关单个实例,请参见此处的示例代码。 https://pqina.nl/filepond/docs/patterns/api/filepond-object/#creating-a-filepond-instance

对于多个实例,它应该类似于:

<input type="file" class="filepond">
<input type="file" class="filepond">
<input type="file" class="filepond">

<script>
// get a collection of elements with class filepond
const inputElements = document.querySelectorAll('input.filepond');

// loop over input elements
Array.from(inputElements).forEach(inputElement => {

  // create a FilePond instance at the input element location
  FilePond.create(inputElement);

})
</script>