<template>
<!-- 省略其他配置 -->
<el-upload ref="upload" :file-list.sync="fileList"></el-upload>
</template>
<script>
import Sortable from 'sortablejs';
export default {
data() {
return {
fileList: []
};
},
mounted() {
this.initDragSort();
},
methods: {
// 支持拖拽排序
initDragSort() {
const el = this.$refs.upload.$el.querySelectorAll('.el-upload-list')[0];
Sortable.create(el, {
onEnd: ({ oldIndex, newIndex }) => {
// 交換位置
const arr = this.fileList;
const page = arr[oldIndex];
arr.splice(oldIndex, 1);
arr.splice(newIndex, 0, page);
}
});
}
}
};
</script>
文章來源地址http://www.zghlxwxcb.cn/news/detail-804577.html
文章來源:http://www.zghlxwxcb.cn/news/detail-804577.html
到了這里,關(guān)于element-ui的el-upload組件實(shí)現(xiàn)上傳拖拽排序圖片順序(sortablejs)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!