在dropzone
(或vue2dropzone
)中,有没有办法禁用文件上传,并且只允许通过拖放添加到 dropzone 。
我有一个设置,我使用自定义预览模板成功设置拖放到 dropzone 中的子区域(可点击: ,),如本期.czs1
AlexanderYW 所示如何手动正确添加文件?.
DropZone 选项:
dropzoneOptions: {
url: 'http://localhost:3000/imageUpload',
thumbnailWidth: 250,
autoProcessQueue: false,
addRemoveLinks: true,
clickable: `.czs1`,
previewTemplate: this.template(),
},
现在我要做的就是禁用 childZone在单击时触发 OS 文件上传对话框。我发现 dropzone 的输入标签隐藏在一个类中dz-hidden-input
<input type="file" class="dz-hidden-input" style="visibility: hidden; position: absolute; top: 0px; left: 0px; height: 0px; width: 0px;">
因此,在下文中,我使用.dz-hidden-input
className 获取输入,然后event.preventDefault()
对每个输入都不起作用。
var dropZoneInput = document.getElementsByClassName('dz-hidden-input')
dropZoneInput.forEach(item => {
item.addEventListener('click', function () {
event.preventDefault()
})
})
是否有在标准 API(由 Dropzone 提供)中实现这一点。如果不是如何解决,因为上述方法document.getElementsByClassName('dz-hidden-input')
不起作用。
谢谢。