首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在rails上使用webpacker的uppy

如何在rails上使用webpacker的uppy
EN

Stack Overflow用户
提问于 2018-11-09 07:36:40
回答 1查看 653关注 0票数 0

我试着在rails上的webpacker上使用uppy,我在工作中遇到了困难:

代码语言:javascript
复制
//  app/javascripts/src/javascript/my_scripts.js    
const Uppy = require('@uppy/core')
const DragDrop = require('@uppy/drag-drop')
const ProgressBar = require('@uppy/progress-bar')

const uppyOne = new Uppy({debug: true, autoProceed: true})
uppyOne.use(DragDrop, { target: '.UppyDragDrop-One' })

这是我收到的控制台错误:

代码语言:javascript
复制
[Uppy] [23:29:46] Not installing DragDrop
Plugin.js:165 Uncaught Error: Invalid target option given to DragDrop. Please make sure that the element 
      exists on the page, or that the plugin you are targeting has been installed. Check that the <script> tag initializing Uppy 
      comes at the bottom of the page, before the closing </body> tag (see https://github.com/transloadit/uppy/issues/1042).
    at DragDrop.mount (Plugin.js:165)
    at DragDrop.install (index.js:204)
    at Uppy.use (index.js:901)
    at Object.<anonymous> (uppy.js:6)
    at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
    at Object.<anonymous> (application.js:1)
    at __webpack_require__ (bootstrap a698a4c3b9adcd1bf843:19)
    at bootstrap a698a4c3b9adcd1bf843:62
    at bootstrap a698a4c3b9adcd1bf843:62
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-13 19:28:37

我发现了这个问题,因为在rails中,通常链接到布局文件头上的所有JS文件,但是类'.UppyDragDrop‘的元素还没有呈现出来。

要解决这个问题,您需要在提供带有javascript_pack_tag元素的元素之后,通过DragDrog单独链接到javascript。

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

https://stackoverflow.com/questions/53221530

复制
相关文章

相似问题

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