最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用element+vuedraggable實現(xiàn)圖片上傳拖拽排序

 更新時間:2022年04月07日 13:47:42   作者:Ronin_zhou  
這篇文章主要為大家詳細介紹了使用element+vuedraggable實現(xiàn)圖片上傳拖拽排序,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了用element+vuedraggable實現(xiàn)圖片上傳拖拽排序的具體代碼,供大家參考,具體內(nèi)容如下

<template>
? ? <div class="allUpload">
? ? ? ? <div class="clearfix">
? ? ? ? ? ? <div class="wrap">
? ? ? ? ? ? ? ? <draggable
? ? ? ? ? ? ? ? ? ? v-model="value" ?
? ? ? ? ? ? ? ? ? ? animation="400"?
? ? ? ? ? ? ? ? ? ? class="clearfix"
? ? ? ? ? ? ? ? >
? ? ? ? ? ? ? ? ? ? <transition-group>

? ? ? ? ? ? ? ? ? ? ? ? <div class="left middleCenter" v-for="(item,index) in value" :key="item.id">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <img :src="item.url" alt="">
? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? <div class="content-wrap">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <div class="content middleCenter">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <i class="el-icon-zoom-in" @click="showImg(item.url)" ></i>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <i class="el-icon-delete" @click="delImg(item,index)"></i>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </div>
? ? ? ? ? ? ? ? ? ? ? ? ? ? </div>
? ? ? ? ? ? ? ? ? ? ? ? </div>
? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? </transition-group>


? ? ? ? ? ? ? ? ? ? <div slot="footer" style="float:left">
? ? ? ? ? ? ? ? ? ? ? ? <el-upload
? ? ? ? ? ? ? ? ? ? ? ? ? ? class="wrap"
? ? ? ? ? ? ? ? ? ? ? ? ? ? list-type="picture-card"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :action="imgUploadUrl"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :show-file-list="false"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :limit="max"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :on-progress="handlePictureCardPreview"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :on-exceed="onExceed"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :disabled="disabled"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :on-change="onChange"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :file-list="fileList"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :multiple="true"
? ? ? ? ? ? ? ? ? ? ? ? ? ? :on-success="handleSuccess"
? ? ? ? ? ? ? ? ? ? ? ? ? ? v-if="isUploadBtn"
? ? ? ? ? ? ? ? ? ? ? ? >
? ? ? ? ? ? ? ? ? ? ? ? ? ? <i slot="default" :class="uploadLoading ? 'el-icon-loading' : 'el-icon-plus'"></i>
? ? ? ? ? ? ? ? ? ? ? ? </el-upload>
? ? ? ? ? ? ? ? ? ? </div>
? ? ? ? ? ? ? ? </draggable>
? ? ? ? ? ? </div>
? ? ? ? ? ??
? ? ? ? </div>
? ? ? ??
? ? ? ? <el-dialog title="查看圖片" :visible.sync="dialogVisible">
? ? ? ? ? ? <img width="100%" :src="dialogImageUrl" alt="">
? ? ? ? </el-dialog>
? ? </div>
</template>

<script>
import draggable from 'vuedraggable'
import {imgUpload} from '@/api/upload'
import {MathRandom} from '@/utils/auth'
import { promises } from 'fs'
export default {
? ? name:'Upload',
? ? data () {
? ? ? ? return {
? ? ? ? ? ? dialogImageUrl: '',
? ? ? ? ? ? uploadLoading:false,
? ? ? ? ? ? dialogVisible: false,
? ? ? ? ? ? disabled: false,
? ? ? ? ? ? fileList:[],
? ? ? ? ? ? imgUploadUrl:imgUpload(),
? ? ? ? ? ? arrs:[]
? ? ? ? }
? ? },
? ? props: {
? ? ? ? value: {
? ? ? ? ? ? type: () => [],
? ? ? ? ? ? default () {
? ? ? ? ? ? ? ? return []
? ? ? ? ? ? }
? ? ? ? },
? ? ? ? max:{
? ? ? ? ? ? type:[Number,String],
? ? ? ? ? ? default:9
? ? ? ? },
? ? ? ? disabled:{
? ? ? ? ? ? type:Boolean,
? ? ? ? ? ? default:false
? ? ? ? }
? ? },
? ? model:{
? ? ? ? event: 'giveActive'
? ? },
? ? computed:{
? ? ? ? isUploadBtn(){
? ? ? ? ? ? return this.value.length<this.max
? ? ? ? },
? ? ? ? imgArr(){
? ? ? ? ? ? return this.value
? ? ? ? }
? ? },

? ? mounted(){
? ? ? ? this.value =[]

? ? ? ? // this.fileList =[]

? ? ? ? const unwatch = this.$watch('value', function(newValue, oldValue){
? ? ? ? ? ? console.log(12312323)
? ? ? ? ? ? this.fileList = newValue
? ? ? ? ? ? unwatch()

? ? ? ? });

? ? },
? ? methods: {
? ? ? ?
? ? ? ? go () {
? ? ? ? ? ? this.$emit('giveActive', this.value);
? ? ? ? },
? ? ? ? showImg(url){
? ? ? ? ? ? this.dialogImageUrl = url
? ? ? ? ? ? this.dialogVisible = true
? ? ? ? },
? ? ? ? delImg(item,index){
? ? ? ? ? ? this.$confirm('此操作將永久刪除該圖片, 是否繼續(xù)?', '提示', {
? ? ? ? ? ? ? ? confirmButtonText: '確定',
? ? ? ? ? ? ? ? cancelButtonText: '取消',
? ? ? ? ? ? ? ? type: 'warning'
? ? ? ? ? ? }).then(() => {
? ? ? ? ? ? ? ? this.value.splice(index,1)
? ? ? ? ? ? ? ? this.fileList.splice(index,1)
? ? ? ? ? ? ? ? this.go()
? ? ? ? ? ? }).catch(() => {
? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? });

? ? ? ? },
? ? ? ? onChange(file,fileList){
? ? ? ? ? ? this.fileList = fileList
? ? ? ? },
? ? ? ??
? ? ? ? handlePictureCardPreview(file) {
? ? ? ? ? ? this.uploadLoading = true
? ? ? ? },
? ? ? ? onExceed(files, fileList,props){
? ? ? ? ? ? this.$message({
? ? ? ? ? ? ? ? message:`超出最大上傳數(shù)量,最多可上傳${this.max}張圖片`,
? ? ? ? ? ? ? ? type:'error'
? ? ? ? ? ? })
? ? ? ? },
? ? ? ? handleSuccess(response, file,fileList) {
? ? ? ? ? ? this.uploadLoading =false
? ? ? ? ? ? this.urlList(response)
? ? ? ? },
? ? ? ? urlList(res){
? ? ? ? ? ? const obj={
? ? ? ? ? ? ? ? id:MathRandom(),
? ? ? ? ? ? ? ? url:res.data.data,
? ? ? ? ? ? ? ? status:'success',
? ? ? ? ? ? ? ? uid:MathRandom()
? ? ? ? ? ? }
? ? ? ? ? ? if(this.value.length<this.max){
? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? this.value = [...this.value,obj]
? ? ? ? ? ? ? ? this.go()
? ? ? ? ? ? }
? ? ? ? ? ??

? ? ? ? }
? ? }
}
</script>

<style lang='scss' scoped>
? ? .allUpload{

? ? ? ? .left{
? ? ? ? ? ? float: left;
? ? ? ? ? ? width: 148px;
? ? ? ? ? ? height: 148px;
? ? ? ? ? ? border-radius: 6px;
? ? ? ? ? ? border: 1px solid #c0ccda;
? ? ? ? ? ? margin:0 20px 20px 0;
? ? ? ? ? ? overflow: hidden;
? ? ? ? ? ? position: relative;
? ? ? ? ? ? cursor: pointer;
? ? ? ? ? ? &:hover{
? ? ? ? ? ? ? ? .content-wrap{
? ? ? ? ? ? ? ? ? ? display: block;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? .content-wrap{
? ? ? ? ? ? ? ? display: block;
? ? ? ? ? ? }
? ? ? ? ? ? img{
? ? ? ? ? ? ? ? max-width: 100%;
? ? ? ? ? ? ? ? max-height: 100%;
? ? ? ? ? ? ? ? object-fit: cover;
? ? ? ? ? ? }
? ? ? ? ? ? .content-wrap{
? ? ? ? ? ? ? ? display: none;
? ? ? ? ? ? ? ? position: absolute;
? ? ? ? ? ? ? ? z-index: 99999999;
? ? ? ? ? ? ? ? width: 100%;
? ? ? ? ? ? ? ? height: 100%;
? ? ? ? ? ? ? ? background:rgba($color: #000000, $alpha: 0.4);
? ? ? ? ? ? ? ? .content{
? ? ? ? ? ? ? ? ? ? width: 100%;
? ? ? ? ? ? ? ? ? ? height: 100%;
? ? ? ? ? ? ? ? ? ? i{
? ? ? ? ? ? ? ? ? ? ? ? color: #fff;
? ? ? ? ? ? ? ? ? ? ? ? font-size: 18px;
? ? ? ? ? ? ? ? ? ? ? ? &:nth-of-type(1){
? ? ? ? ? ? ? ? ? ? ? ? ? ? margin-right: 10px;
? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? &:nth-of-type(2){
? ? ? ? ? ? ? ? ? ? ? ? ? ? margin-left: 10px;
? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ??
? ? ? ? }
? ? ? ??
? ? ? ? .wrap{
? ? ? ? ? ? float: left;
? ? ? ? }
? ? }
</style>

效果圖

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue中使用element日歷組件的示例代碼

    vue中使用element日歷組件的示例代碼

    這篇文章主要介紹了vue中如何使用element的日歷組件,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-09-09
  • vue history 模式打包部署在域名的二級目錄的配置指南

    vue history 模式打包部署在域名的二級目錄的配置指南

    這篇文章主要介紹了vue history 模式打包部署在域名的二級目錄的配置指南 ,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-07-07
  • Vue項目開發(fā)常見問題和解決方案總結(jié)

    Vue項目開發(fā)常見問題和解決方案總結(jié)

    這篇文章主要介紹了Vue項目開發(fā)常見問題和解決方案總結(jié),幫助大家更好的利用vue開發(fā),感興趣的朋友可以了解下
    2020-09-09
  • vue3中的ref、reactive問題解析

    vue3中的ref、reactive問題解析

    ref 和 reactive都是vue3推出的針對組合式設(shè)計的聲明響應(yīng)式狀態(tài)的API,兩者在使用之前都要先進行引入,本文通過實例代碼詳解vue3中的ref、reactive問題,感興趣的朋友一起看看吧
    2024-03-03
  • 解決iView Table組件寬度只變大不變小的問題

    解決iView Table組件寬度只變大不變小的問題

    這篇文章主要介紹了解決iView Table組件寬度只變大不變小的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-11-11
  • vue3項目中的el-carousel 輪播圖的使用

    vue3項目中的el-carousel 輪播圖的使用

    Carousel(走馬燈)是一種常見的前端組件,通常用于展示多個項目(通常是圖片或內(nèi)容塊)的輪播效果,這篇文章主要介紹了vue3項目中的el-carousel 輪播圖的使用,需要的朋友可以參考下
    2024-02-02
  • 在Vue中實現(xiàn)不刷新的iframe頁面的方案

    在Vue中實現(xiàn)不刷新的iframe頁面的方案

    在Vue項目中,我們可能會遇到這樣的需求:需要在應(yīng)用中嵌入iframe頁面,并且要求在路由切換的過程中,iframe的內(nèi)容不會被刷新,本文將介紹如何解決這個問題,并給出具體的實現(xiàn)方案,需要的朋友可以參考下
    2025-01-01
  • vue.js如何處理數(shù)組對象中某個字段是否變?yōu)閮蓚€字段

    vue.js如何處理數(shù)組對象中某個字段是否變?yōu)閮蓚€字段

    這篇文章主要介紹了vue.js如何處理數(shù)組對象中某個字段是否變?yōu)閮蓚€字段方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • vue集成chart.js的實現(xiàn)方法

    vue集成chart.js的實現(xiàn)方法

    這篇文章主要介紹了vue集成chartjs的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • Vue基于環(huán)境變量統(tǒng)一的多級路徑部署終極指南

    Vue基于環(huán)境變量統(tǒng)一的多級路徑部署終極指南

    這篇文章主要為大家詳細介紹了一個完整的解決方案,從環(huán)境變量配置到Nginx部署,確保你的Vue項目可以靈活部署在任何路徑下,下面小編就為大家簡單介紹一下吧
    2025-08-08

最新評論

广河县| 房产| 揭西县| 清水河县| 清涧县| 肥乡县| 奈曼旗| 凌海市| 连山| 苏尼特左旗| 仁寿县| 汝南县| 平利县| 巴彦淖尔市| 龙州县| 宜州市| 奉节县| 延边| 琼结县| 商河县| 曲阳县| 南漳县| 建平县| 屯昌县| 郧西县| 贵南县| 上林县| 河南省| 泗阳县| 循化| 什邡市| 健康| 鄂伦春自治旗| 阿图什市| 抚顺县| 海原县| 唐河县| 梅河口市| 彭州市| 中牟县| 临清市|