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

vue實現(xiàn)element上傳多張圖片瀏覽刪除功能

 更新時間:2023年10月13日 10:22:31   作者:小鄭  
這篇文章主要介紹了vue實現(xiàn)element上傳多張圖片瀏覽刪除功能,本文結合示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧

vue原生實現(xiàn)element上傳多張圖片瀏覽刪除

<div class="updata-component" style="width:100%;">
   <div class="demo-upload-box clearfix">
     <div class="demo-upload-image-box" v-if="imageUrlArr && imageUrlArr.length">
       <div class="demo-upload-image" v-for="(item,index) in imageUrlArr" :key="index">
         <img :src="item">
         <div class="demo-upload-box-cover">
          <!-- 點擊刪除 -->
           <i class="el-icon-delete" style="position: absolute;left: 30%;top: 80%;z-index:2;color:#fff;"
             @click="handleRemoves(index)"></i>
              <!-- 點擊瀏覽 -->
             <i class="el-icon-zoom-in" @click="handleView(index)" style="position: absolute;left: 56%;top: 80%;z-index:2;color:#fff;"></i>
         </div>
       </div>
     </div>
     <div class="demo-upload-btn" v-show="isshowlng">
       <input ref="uploadInput" type="file" class="file" @change="handleSuccess">
       <i slot="default" class="el-icon-plus"></i>
       <input type="button" class="btn" @click="clickFile" />
     </div>
   </div>
   <!-- 查看大圖 -->
   <el-dialog :visible.sync="dialogVisible" :modal-append-to-body="false">
       <img width="100%" :src="bigPicSrc" alt="">
     </el-dialog>
 </div>
data(){
	return{
		bigPicSrc: '',
        imageUrlArr: [],//頁面展示url數(shù)組
        filesData: [],//file數(shù)組
        isshowlng:true,//判斷上傳圖片按鈕是否顯示
	}
},
methods:{
	// 文件上傳接收
    handleSuccess (e) {
      console.log('------',e)
      console.log('imgs.lenght',this.imgs.length)
      var lng=6-this.imgs.length
      console.log('lng',lng)
      let file = e.target
      for (let i = 0; i < file.files.length; i++) {
        this.imageUrlArr.push(window.URL.createObjectURL(file.files.item(i)))
        this.filesData.push(file.files[i])
      }
      console.log('this.filesData',this.filesData)
      console.log('this.filesData.length',this.filesData.length)
      if(this.filesData.length>=lng){
        this.isshowlng=false
      }else{
        this.isshowlng=true
      }
    },
    clickFile () {
      const input = this.$refs.uploadInput
      input.click()
    },
    // 刪除上傳的案例圖
    handleRemoves (index) {
      console.log('刪除')
      this.imageUrlArr.splice(index, 1)
      this.filesData.splice(index, 1)
      var lng=6;//限制最多上傳6張
      if(this.filesData.length>=lng){
        this.isshowlng=false
      }else{
        this.isshowlng=true
      }
      this.$forceUpdate()
    },
    // 查看大圖
    handleView (index) {
      console.log('查看大圖')
      this.dialogVisible=true
      this.bigPicSrc = this.imageUrlArr[index]
    },
}
<style>
/* ------------------------- */
.demo-upload-image-box{
  height: 150px;
  /* width: 120px; */
  /* padding: 10px; */
  float: left;
}
.demo-upload-btn{
  width: 115px;
  height: 115px;
  background-color: #fbfdff;
  border: 1px dashed #c0ccda;
  border-radius: 6px;
  text-align: center;
  position: relative;
  float: left;
}
.demo-upload-image{
  width: 117px;
  height: 117px;
  margin-right: 5px;
  display: inline-block;
  position: relative;
}
.demo-upload-image img{
  width: 115px;
  height: 115px;
}
.big-pic{
  position: fixed;
    left: 40%;
    top: 20%;
}
.big-pic img{
  width: 400px;
  height: 300px;
}
.file {
  width: 115px;
  height: 115px;
  display: none;
}
.btn {
  position: absolute;
  top: 0;
  left: 0;
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0);
  z-index: 10;
  border: none;
  cursor: pointer;
}
.demo-upload-btn .el-icon-plus{
  line-height: 110px;
  font-size: 16px;
  /* position: absolute;
    left: 40px; */
}
.el-icon-plus:before{
  font-size: 30px;
  color: #8c939d;
}
.demo-upload-box-cover{
  background: rgba(0,0,0,0.3);
  width: 100%;
  height: 100%;
  position:absolute;
  left:0;
  top:0;
  border-radius:5px;
}
</style>

到此這篇關于vue實現(xiàn)element上傳多張圖片瀏覽刪除功能的文章就介紹到這了,更多相關vue element上傳多張圖片內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Vue面試題及Vue知識點整理

    Vue面試題及Vue知識點整理

    這篇文章主要介紹了Vue面試題及Vue知識點整理,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友參考下吧
    2018-10-10
  • element實現(xiàn)合并單元格通用方法

    element實現(xiàn)合并單元格通用方法

    這篇文章主要介紹了element實現(xiàn)合并單元格通用方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-11-11
  • Vue + element 實現(xiàn)多選框組并保存已選id集合的示例代碼

    Vue + element 實現(xiàn)多選框組并保存已選id集合的示例代碼

    這篇文章主要介紹了Vue + element 實現(xiàn)多選框組并保存已選id集合,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-06-06
  • vue3?使用?vue3-video-play實現(xiàn)在線視頻播放

    vue3?使用?vue3-video-play實現(xiàn)在線視頻播放

    這篇文章主要介紹了vue3?使用?vue3-video-play?進行在線視頻播放,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-06-06
  • Vue+Openlayer批量設置閃爍點的實現(xiàn)代碼(基于postrender機制)

    Vue+Openlayer批量設置閃爍點的實現(xiàn)代碼(基于postrender機制)

    本篇文章給大家介紹基于postrender機制使用Vue+Openlayer批量設置閃爍點的實現(xiàn)代碼,代碼簡單易懂,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2021-09-09
  • Vue使用Canvas生成隨機大小且不重疊圓

    Vue使用Canvas生成隨機大小且不重疊圓

    Canvas是HTML5中新增的元素,專門用來繪制圖形,下面這篇文章主要給大家介紹了關于Vue使用Canvas生成隨機大小且不重疊圓的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2021-11-11
  • vue webuploader 文件上傳組件開發(fā)

    vue webuploader 文件上傳組件開發(fā)

    本篇文章主要介紹了vue webuploader 文件上傳組件開發(fā),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09
  • vue @vuelidate父子組件綁定注意事項

    vue @vuelidate父子組件綁定注意事項

    Vue@vuelidate父子組件驗證時,不能直接綁定,需在子組件驗證方法內部進行綁定,以避免父組件驗證時包含子組件的驗證
    2025-02-02
  • vue3全局導入bootstrap5方式

    vue3全局導入bootstrap5方式

    這篇文章主要介紹了vue3全局導入bootstrap5方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • Vue開發(fā)中Jwt的使用詳解

    Vue開發(fā)中Jwt的使用詳解

    Vue中使用JWT進行身份認證也是一種常見的方式,它能夠更好地保護用戶的信息,本文主要介紹了Vue開發(fā)中Jwt的使用詳解,具有一定的參考價值,感興趣的可以了解一下
    2023-12-12

最新評論

琼中| 会同县| 原阳县| 班戈县| 恩平市| 陵水| 东丰县| 牙克石市| 临夏县| 会昌县| 仙桃市| 钟山县| 原平市| 四会市| 平塘县| 会昌县| 千阳县| 措美县| 西吉县| 涪陵区| 临清市| 松原市| 宜昌市| 阿尔山市| 博白县| 封丘县| 西贡区| 湖南省| 娱乐| 华蓥市| 瑞安市| 科尔| 来安县| 法库县| 绥芬河市| 逊克县| 英山县| 兰考县| 福安市| 江西省| 鄂托克旗|