本文介绍: 阅读官网 发现主要通过filtlist来进行回显 要把后端的传回来的数据改为 有url格式下图图片回显我们要对个别图片进行删除 主要是 :onremove=”handleRemovethis.detilData.item_image 就是我们传过去的数组res.data.list.item_image接口返回图片数组。他有两个参数 如果我们需要图片url 都放在一个数组里,传给后端。我们页面获取接口数据的地方 ,改为 有url格式来进行回显elementui官方文档

elementui官方文档 Element – The world’s most popular Vue UI framework

阅读官网 发现主要通过filtlist来进行回显  要把后端的传回来的数据改为 有url的格式 如下图

代码展示

<el-upload
     :action="upurl" 
     :headers="upheaders"
     :limit="10"
     list-type="picture-card"
     :on-preview="handlePreview"
     :on-remove="handleRemove"
     :on-success="handleSuccess"
     :on-error="handleError"
     :file-list="fileList" 
     :class="{ disabled: uploadDisabled }"
     ref="upload">
 </el-upload&gt;

我们页面获取接口数据的地方 ,改为 有url的格式来进行回显

 this.fileList = res.data.list.item_image.map(t =&gt; {
      var obj = {}
      obj.url = t
      return obj
  })

res.data.list.item_image接口返回图片数组 

页面可以进行回显了

图片回显后我们要对个别图片进行删除 主要是 :onremove=”handleRemove”

他有两个参数 如果我们需要把图片的url 都放在一个数组里,传给后端

 handleRemove(file, fileList) {
     let arr = []
     for (let i of fileList) {
        arr.push(i.url);
      }
     this.detilData.item_image = arr
},

this.detilData.item_image 就是我们传过去的数组 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注