gpt4 book ai didi

javascript - 获取错误 Dropzone 已经附加了 Angular Directive(指令)

转载 作者:可可西里 更新时间:2023-11-01 02:31:48 26 4
gpt4 key购买 nike

我正在为拖放区使用以下代码,但出现错误,我尝试对其进行调试,但我无法解决此操作请指导

http://jsfiddle.net/anam123/rL6Bh/

 -------------------> "Error: Dropzone already attached.

throw new Error("Dropzone already attached.");"

代码::

https://gist.github.com/compact/8118670

片段:

 /**
* An AngularJS directive for Dropzone.js, http://www.dropzonejs.com/
*
* Usage:
*
* <div ng-app="app" ng-controller="SomeCtrl">
* <button dropzone="dropzoneConfig">
* Drag and drop files here or click to upload
* </button>
* </div>
*/

angular.module('dropzone', []).directive('dropzone', function () {
return function (scope, element, attrs) {
var config, dropzone;

config = scope[attrs.dropzone];

// create a Dropzone for the element with the given options
dropzone = new Dropzone(element[0], config.options);

// bind the given event handlers
_.each(config.eventHandlers, function (handler, event) {
dropzone.on(event, handler);
});
};
});

angular.module('app', ['dropzone']);

angular.module('app').controller('SomeCtrl', function ($scope) {
$scope.dropzoneConfig = {
'options': { // passed into the Dropzone constructor
'url': 'upload.php'
},
'eventHandlers': {
'sending': function (file, xhr, formData) {
},
'success': function (file, response) {
}
}
};
});

最佳答案

使用以下代码设置解决了问题。

所以你可以:

  1. 像这样全局关闭自动发现:Dropzone.autoDiscover = false;,或者
  2. 关闭特定元素的自动发现,例如 这:Dropzone.options.myAwesomeDropzone = false;

引用:
FAQ on dropzone

关于javascript - 获取错误 Dropzone 已经附加了 Angular Directive(指令),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24118187/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com