我无法在Filepond上使用图像预览

时间:2019-04-07 01:07:47

标签: filepond

为了使它正常工作,我已经做了一切,但是还没有工作

我从CDN加载,就像预览文档中一样

<!-- add to document <head> -->
<link href="https://unpkg.com/filepond/dist/filepond.css" 
rel="stylesheet">
<link href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond- 
plugin-image-preview.css" rel="stylesheet">

<!-- add before </body> -->
<script src="https://unpkg.com/filepond-plugin-image- 
preview/dist/filepond-plugin-image-preview.js"></script>
<script src="https://unpkg.com/filepond/dist/filepond.js"></script>

要增强为我拥有的filepond元素

<script>
const inputElement = document.querySelector('input[type="file"]');
const pond = FilePond.create( inputElement );
</script>

最后

<input type="file">

它只是显示为文件,而不显示图像预览。我想念什么?

1 个答案:

答案 0 :(得分:0)

这些插件尚未在FilePond中注册。

这应该有效:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FilePond Plugin Image Preview Demo</title>
    <link href="https://unpkg.com/filepond/dist/filepond.css" rel="stylesheet">
    <link href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css" rel="stylesheet">
</head>
<body>

    <input type="file"/>

    <script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.js"></script>
    <script src="https://unpkg.com/filepond/dist/filepond.js"></script>

    <script>
    // Register the plugin with FilePond
    FilePond.registerPlugin(FilePondPluginImagePreview);

    // Get a reference to the file input element
    const inputElement = document.querySelector('input[type="file"]');

    // Create the FilePond instance
    const pond = FilePond.create(inputElement);
    </script>

</body>
</html>

此处为现场演示:https://pqina.github.io/filepond-plugin-image-preview/

我正在查看the docs,我发现这很令人困惑,有空的话会尽快改善它们。