Skip to content

Commit 3fb128a

Browse files
committed
fix: 修复上传组件被多次引用拖动仅对第一个有效的问题
1 parent b8e3acb commit 3fb128a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ruoyi-fastapi-frontend/src/components/FileUpload/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</el-upload>
2929

3030
<!-- 文件列表 -->
31-
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
31+
<transition-group ref="uploadFileList" class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
3232
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
3333
<el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
3434
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
@@ -105,7 +105,7 @@ export default {
105105
mounted() {
106106
if (this.drag) {
107107
this.$nextTick(() => {
108-
const element = document.querySelector('.upload-file-list')
108+
const element = this.$refs.uploadFileList?.$el || this.$refs.uploadFileList
109109
Sortable.create(element, {
110110
ghostClass: 'file-upload-darg',
111111
onEnd: (evt) => {

ruoyi-fastapi-frontend/src/components/ImageUpload/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default {
104104
mounted() {
105105
if (this.drag) {
106106
this.$nextTick(() => {
107-
const element = document.querySelector('.el-upload-list')
107+
const element = this.$refs.imageUpload?.$el?.querySelector('.el-upload-list')
108108
Sortable.create(element, {
109109
onEnd: (evt) => {
110110
const movedItem = this.fileList.splice(evt.oldIndex, 1)[0]

0 commit comments

Comments
 (0)