這裏采用(yòng)自定義縮略圖模版,定義排序按鈕。
頁(yè)面代碼
<el-upload action="#" :file-list="imageList" list-type="picture-card">
<i class="el-icon-plus avatar-uploader-icon"></i>
<div slot="file" slot-scope="{file}" style="width: 100%;height: 100%;">
<!-- <img class="el-upload-list__item-thumbnail" :src="file.url" alt=""> -->
<el-image v-if="file.status !== 'uploading'" style="width: 100px; height: 100px" :src="file.url" fit="contain"></el-image>
<label class="el-upload-list__item-status-label">
<i class="el-icon-upload-success el-icon-check"></i>
</label>
<span class="el-upload-list__item-actions">
<span class="el-upload-list__item-delete" @click="handleMove(file)">
<i class="el-icon-back"></i>
</span>
<span class="el-upload-list__item-delete" @click="handleRemove(file)">
<i class="el-icon-delete"></i>
</span>
</span>
<el-progress v-if="file.status === 'uploading'" type="circle" stroke-width="6"
:percentage="parseInt(file.percentage, 10)">
</el-progress>
</div>
</el-upload>
JS
點擊按鈕圖片向前移動一格
handleMove(file) {
let idx;
this.images.forEach((image, index) => {
if (image.url == file.url) {
idx = index;
}
})
console.log(idx)
if (idx > 0) {
let tmp = this.imageList[idx - 1];
Vue.set(this.imageList, idx - 1, this.imageList[idx])
Vue.set(this.imageList, idx, tmp)
}
},
按圖片順序保存序号即可(kě)。
- 版權所有(yǒu):奇站網絡 轉載請注明出處
- 廈門奇站網絡科(kē)技(jì )有(yǒu)限公(gōng)司,專業提供網站建設,響應式網站建設,小(xiǎo)程序開發,系統定制開發。
- 軟件開發咨詢熱線(xiàn):吳小(xiǎo)姐 13313868605