首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Javascript不适用于FilePond

Javascript不适用于FilePond
EN

Stack Overflow用户
提问于 2020-03-17 06:16:07
回答 1查看 180关注 0票数 1

我正在使用filepond上传文件到我的web应用程序。我使用head标记中的所有脚本,使用延迟,但它们没有加载脚本。但是,当我将它们放在输入文件类型之后的body标记中时,它们将正确加载,filepond也在工作。同样,当我在正文中对相同的脚本使用defer时,filepond停止工作。我正在对模板文件进行注册:

代码语言:javascript
复制
<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <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">

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

        <!-- <script defer src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.js"></script>
        <script defer src="https://unpkg.com/filepond-plugin-file-encode/dist/filepond-plugin-file-encode.js"></script>
        <script defer src="https://unpkg.com/filepond-plugin-image-resize/dist/filepond-plugin-image-resize.js"></script>
        <script defer src="https://unpkg.com/filepond/dist/filepond.js"></script>
        <script>
            FilePond.registerPlugin(FilePondPluginImagePreview);
            FilePond.registerPlugin(FilePondPluginImageResize);
            FilePond.registerPlugin(FilePondPluginFileEncode);
            const inputElement = document.querySelector('input[type="file"]');
            const pond = FilePond.create(inputElement);
            FilePond.parse(document.body);
        </script> -->
        <title>Mybrary</title>
    </head>
    <body>
        <!-- <input type="file" class="filepond"> -->
        <script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.js"></script>
        <script src="https://unpkg.com/filepond-plugin-file-encode/dist/filepond-plugin-file-encode.js"></script>
        <script src="https://unpkg.com/filepond-plugin-image-resize/dist/filepond-plugin-image-resize.js"></script>
        <script src="https://unpkg.com/filepond/dist/filepond.js"></script>
        <script>
            FilePond.registerPlugin(FilePondPluginImagePreview);
            FilePond.registerPlugin(FilePondPluginImageResize);
            FilePond.registerPlugin(FilePondPluginFileEncode);
            const inputElement = document.querySelector('input[type="file"]');
            const pond = FilePond.create(inputElement);
            FilePond.parse(document.body);
        </script>
    </body>
    </html>

有人能告诉我为什么延期不起作用吗?

(P.S. -我使用ejs作为视图模板)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-17 06:32:28

延迟属性是浏览器特有的http://caniuse.com/#feat=script-defer (感谢atm)。

如果src属性不存在,则不能指定延迟和异步属性。

检查你的第二个案子。检查此URL

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60717102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档