我认为这部分导致了这个问题:
// Query all needed elements in one go
const [dropZone, showSelectedImages, fileUploader] = document.querySelectorAll(
"#standard-upload-files, #drop-zone, #show-selected-images"
);
这样查询元素是非常糟糕的做法,因为如果不更改解构数组中的元素,就无法更改它们在html中的顺序。在您的情况下,您最终正在移动预览,现在您的
showSelectedImages
变量实际上是上传器,并且
fileUploader
现在是保存预览的div,一切都一团糟。
您需要逐一查询:
const fileUploader = document.getElementById('standard-upload-files');
const dropZone = document.getElementById('drop-zone');
const showSelectedImages = document.getElementById('show-selected-images');