vue2-dropzone 不提供点击事件,但您可以创建自己的点击事件。当
vdropzone-file-added
事件触发时(每当将文件添加到拖放区时都会发生这种情况),您可以使用它来添加单击事件侦听器
<vue-dropzone
ref="myVueDropzone"
:options="dropzoneOptions"
@vdropzone-file-added="added">
</vue-dropzone>
added(file) {
if (file.previewElement) {
// get details overlay element that appears when hovering a thumbnail
const detailsElement = file.previewElement.querySelector('.dz-details');
// add click listener to it
detailsElement.addEventListener('click', () => {
this.fileClick(file);
});
}
},
fileClick(file) {
const url = URL.createObjectURL(file);
window.open(url);
}