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

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

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

vue原生實(shí)現(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">
          <!-- 點(diǎn)擊刪除 -->
           <i class="el-icon-delete" style="position: absolute;left: 30%;top: 80%;z-index:2;color:#fff;"
             @click="handleRemoves(index)"></i>
              <!-- 點(diǎn)擊瀏覽 -->
             <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>

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

相關(guān)文章

  • Vue面試題及Vue知識點(diǎn)整理

    Vue面試題及Vue知識點(diǎn)整理

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

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

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

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

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

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

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

    Vue+Openlayer批量設(shè)置閃爍點(diǎn)的實(shí)現(xiàn)代碼(基于postrender機(jī)制)

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

    Vue使用Canvas生成隨機(jī)大小且不重疊圓

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

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

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

    vue @vuelidate父子組件綁定注意事項(xiàng)

    Vue@vuelidate父子組件驗(yàn)證時(shí),不能直接綁定,需在子組件驗(yàn)證方法內(nèi)部進(jìn)行綁定,以避免父組件驗(yàn)證時(shí)包含子組件的驗(yàn)證
    2025-02-02
  • vue3全局導(dǎo)入bootstrap5方式

    vue3全局導(dǎo)入bootstrap5方式

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

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

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

最新評論

五原县| 建水县| 清水河县| 岐山县| 岱山县| 黄浦区| 文成县| 博野县| 辽源市| 霸州市| 拉萨市| 扶余县| 蒙阴县| 夹江县| 大关县| 嘉黎县| 黎城县| 宜宾县| 江津市| 齐河县| 顺义区| 和田县| 忻州市| 桓台县| 双桥区| 印江| 永丰县| 诏安县| 沂源县| 永嘉县| 资兴市| 阿克苏市| 泰和县| 呼伦贝尔市| 哈巴河县| 双辽市| 平遥县| 高邑县| 揭阳市| 恩施市| 五峰|