DropZone:“没有提供URL”和“Dropzone已经附加”。

时间:2018-03-15 01:36:53

标签: javascript jquery image dropzone.js

我正在使用dropzone和jquery。我有这段代码:

  <div id="my-image">
    <!-- .......... -->
  </div>

  <script type="text/javascript">
    Dropzone.autoDiscover = false;

    $(document).ready(function() {
      var image_uploader = new Dropzone("#upload-image", {url: "/image_uploader", acceptedFiles : "image/*",
                                                          maxFiles: 1, maxFilesize: 1, autoDiscover: false});

      //.................

然而我有这两个错误:

//dropzone.js:712
Uncaught Error: No URL provided.
    at new Dropzone (dropzone.js:712)
    at Function.Dropzone.discover (dropzone.js:1641)
    at Dropzone._autoDiscoverFunction (dropzone.js:1923)
    at HTMLDocument.init (dropzone.js:1892)

//jquery-3.3.1.min.js:2

Uncaught Error: Dropzone already attached.
  at new Dropzone (dropzone.js:699)
  at HTMLDocument.<anonymous> ((index):221)
  at l (jquery-3.3.1.min.js:2)
  at c (jquery-3.3.1.min.js:2)

他们为什么会这样?如何修复它们?

1 个答案:

答案 0 :(得分:2)

对于第一个错误,您必须在<Input key={propName[0]} label={propName[0]} value={propName[1]} onValueChange={event => this.props.changed(propName[0], event)} /> 之前添加Dropzone.autoDiscover = false;

对于第二个错误,我认为您已经两次声明了Dropzopne.js。