欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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>

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

相關(guān)文章

  • uniapp項目國際化標(biāo)準(zhǔn)的配置與實現(xiàn)

    uniapp項目國際化標(biāo)準(zhǔn)的配置與實現(xiàn)

    UniApp是一種基于Vue.js的跨平臺開發(fā)框架,可以快速地開發(fā)同時運行在多個平臺的應(yīng)用程序,這篇文章主要介紹了uniapp項目國際化標(biāo)準(zhǔn)的配置與實現(xiàn),需要的朋友可以參考下
    2023-11-11
  • vue-cli3配置多項目并按項目分別實現(xiàn)打包

    vue-cli3配置多項目并按項目分別實現(xiàn)打包

    這篇文章主要介紹了vue-cli3配置多項目并按項目分別實現(xiàn)打包方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • Vue3使用vue-router如何實現(xiàn)路由跳轉(zhuǎn)與參數(shù)獲取

    Vue3使用vue-router如何實現(xiàn)路由跳轉(zhuǎn)與參數(shù)獲取

    這篇文章主要介紹了Vue3使用vue-router如何實現(xiàn)路由跳轉(zhuǎn)與參數(shù)獲取,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • vue-cli3 karma單元測試的實現(xiàn)

    vue-cli3 karma單元測試的實現(xiàn)

    這篇文章主要介紹了vue-cli3 karma單元測試的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • 裝飾者模式在日常開發(fā)中的縮影和vue中的使用詳解

    裝飾者模式在日常開發(fā)中的縮影和vue中的使用詳解

    這篇文章主要為大家介紹了裝飾者模式在日常開發(fā)中的縮影和vue中的使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-12-12
  • 解決vue3項目打包后部署后某些靜態(tài)資源圖片不加載問題

    解決vue3項目打包后部署后某些靜態(tài)資源圖片不加載問題

    這篇文章主要給大家介紹了如何解決vue3項目打包后部署后某些靜態(tài)資源圖片不加載問題,文中通過圖文結(jié)合的方式講解的非常詳細(xì),有需要的朋友可以參考下
    2024-05-05
  • vue自定義實例化modal彈窗功能的實現(xiàn)

    vue自定義實例化modal彈窗功能的實現(xiàn)

    這篇文章主要介紹了vue自定義實例化modal彈窗,Vue.extend 屬于Vue的全局 api,在實際業(yè)務(wù)開發(fā)中我們很少使用,因為相比常用的 Vue.component寫法使用 extend 步驟要更加繁瑣一些,本文結(jié)合實例代碼給大家介紹的非常詳細(xì),需要的朋友參考下
    2022-09-09
  • Vue.js中provide/inject實現(xiàn)響應(yīng)式數(shù)據(jù)更新的方法示例

    Vue.js中provide/inject實現(xiàn)響應(yīng)式數(shù)據(jù)更新的方法示例

    這篇文章主要介紹了Vue.js中provide/inject實現(xiàn)響應(yīng)式數(shù)據(jù)更新,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • Vue3+TS項目中eslint、prettier安裝配置詳細(xì)指南

    Vue3+TS項目中eslint、prettier安裝配置詳細(xì)指南

    為了更好的統(tǒng)一項目的代碼風(fēng)格,因此在編寫時就可以使用eslint+prettier,它們不僅能方便代碼編寫,還能避免不必要的錯誤,讓代碼變得更加嚴(yán)謹(jǐn),這篇文章主要給大家介紹了關(guān)于Vue3+TS項目中eslint、prettier安裝配置的相關(guān)資料,需要的朋友可以參考下
    2024-07-07
  • Vue3中vue-router的使用方法詳解

    Vue3中vue-router的使用方法詳解

    Vue?Router?是?Vue?的官方路由,它與?Vue.js?核心深度集成,讓用?Vue.js?構(gòu)建單頁應(yīng)用變得輕而易舉,本文將通過簡單的示例為大家介紹一下vue-router的使用,需要的可以參考一下
    2023-06-06

最新評論