diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 49ead36..d217897 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -42,6 +42,7 @@ +// 初始化拖拽排序 +onMounted(() => { + if (props.drag) { + nextTick(() => { + const element = document.querySelector('.upload-file-list') + Sortable.create(element, { + ghostClass: 'file-upload-darg', + onEnd: (evt) => { + const movedItem = fileList.value.splice(evt.oldIndex, 1)[0] + fileList.value.splice(evt.newIndex, 0, movedItem) + emit('update:modelValue', listToString(fileList.value)) + } + }) + }) + } +}) +