elementUI多图上传图片闪动问题

我们使用elementUI多图上传时

 <el-upload
                      :action='uploadfileurl'
                      list-type="picture-card"
                      name="file"
                      :on-success="handleAvatarSuccess"
                      :headers="myHeaders"
                      :file-list="fileList"
                      :on-remove="handleRemove">
                      <i class="el-icon-plus"></i>
                    </el-upload>

 

data声明变量  fileList:[]

 

js代码

handleAvatarSuccess有三个返回参数,大家一般就直接用第一个参数拿到数据就完事了,其实第三个参数会直接返回
handleRemove(file, fileList) {
         
        this.fileList=fileList
      },
      handleAvatarSuccess(res, file,fileList) {        
        if(res.code==1){
          // this.fileList.push({url:res.data.fullurl})//以前的错误代码
          this.fileList=fileList
        }
      },

 

最后整理一下我们想要的一维数组数据格式就可以了

var image=this.fileList.map(row=>{
     return  row.response.data.fullurl//接口这边返回的是fullurl
})

  

 

posted @ 2022-08-12 15:22  三线码工  阅读(1204)  评论(0编辑  收藏  举报