elementUI多图上传图片闪动问题

我们使用elementUI多图上传时

1
2
3
4
5
6
7
8
9
10
<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代码

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

 

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

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

  

 

posted @   三线码工  阅读(1235)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示