dropzonejs无效的问题
正常效果代码为例2,test是加载vue页面的地方。
例1:
如果把
<div class="container" id="container" style="margin-left:192px">
<form action="/uimg" class="dropzone" id="new-theme" method="post">
</form>
</div>
放在vue组件中,在mounted中初始化dropzonejs,或者在全局初始化dropzonejs,都会无效,而且没报错。
例2:
<body>
<div id="test"></div>
<div class="container" id="container" style="margin-left:192px">
<form action="/uimg" class="dropzone" id="new-theme" method="post">
</form>
</div>
</body>
<script src="js/lib/dropzone/dist/dropzone.js"></script>
<script>
var minSteps = 6,
maxSteps = 60,
timeBetweenSteps = 100,
bytesPerStep = 100000;
Dropzone.prototype.uploadFiles = function(files) {
var self = this;
for (var i = 0; i < files.length; i++) {
var file = files[i];
totalSteps = Math.round(Math.min(maxSteps, Math.max(minSteps, file.size / bytesPerStep)));
for (var step = 0; step < totalSteps; step++) {
var duration = timeBetweenSteps * (step + 1);
setTimeout(function(file, totalSteps, step) {
return function() {
file.upload = {
progress: 100 * (step + 1) / totalSteps,
total: file.size,
bytesSent: (step + 1) * file.size / totalSteps
};
self.emit('uploadprogress', file, file.upload.progress, file.upload.bytesSent);
if (file.upload.progress == 100) {
file.status = Dropzone.SUCCESS;
self.emit("success", file, 'success', null);
self.emit("complete", file);
self.processQueue();
}
};
}(file, totalSteps, step), duration);
}
}
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
mouted中实例化就行了
具体配置参数还有很多,参照文档和需求做就行
http://wxb.github.io/dropzone...