关于javascript:vue-dropzone不会在文件添加时生成缩略图

vue-dropzone doesn't generate thumbnails on file add

我想将服务器上已经存在的文件添加到Dropzone,我尝试通过vue-dropzone Docs以及正常的dropzone docs搜索我的问题,我也经历了5+ github问题,并尝试了那里的帮助方法,但是 似乎没有找到解决方法。

所以我叫这个方法:

1
2
3
4
    this.product.images.forEach(image => {
      const file = { name: 'Icon', type: 'image/jpeg', dataURL: image };
      this.$refs.dropzone.manuallyAddFile(file, image);
    });

文件正确添加,但是我根本没有生成任何缩略图。 这基本上就是整个问题。


您可以使用emit手动添加缩略图:

1
2
3
4
5
6
this.product.images.forEach(image => {
      const file = { name: 'Icon', type: 'image/jpeg', dataURL: image };
      this.$refs.dropzone.manuallyAddFile(file, image);
      this.$refs.dropzone.dropzone.emit('thumbnail', file, file.dataURL)
      this.$refs.dropzone.dropzone.emit('complete', file)
    });

如果您的参考文献是dropzone,则需要转到this.$refs.dropzone.dropzone

并且您需要在@vdropzone-mounted="loadPictures"中调用您的方法。

祝好运!