element-ui中表格中嵌套上传图片

15 篇文章 0 订阅
11 篇文章 0 订阅

实现效果描述:将列表中每一行的两张图片保存到一个对象中,再将所有对象保存到数组中,点击提交时一起提交。
在这里插入图片描述
实现方法:
一,元素中
action="/" :http-request="(file)=>{return imggreySuccess(file ,scope.row)}"
这两句很重要,将上传的文件和列表的这一行的数据通过函数传过去,可以在函数中接收到数据,file就是上传的图片的数据文件

<el-table
                    :data="getGiftListTableData"
                    border
                    style="width: 100%">
                    <el-table-column
                      prop="giftName"
                      label="礼物名称"
                      width="180">
                    </el-table-column>
                    <!-- prop="imggrey" -->
                    <el-table-column
                      label="礼物灰图"
                      width="180">
                      <template slot-scope="scope">
                        <el-upload  file-list='imggrey' action="/" :http-request="(file)=>{return imggreySuccess(file ,scope.row)}"  list-type="picture">
                          <el-button size="small" type="primary">点击选择图片</el-button>
                          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件</div>
                        </el-upload>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="imgColor"
                      label="礼物彩图">
                      <el-upload  file-list='imggrey' action="/" :http-request="(file)=>{return imgColorSuccess(file ,scope.row)}"  list-type="picture">
                          <el-button size="small" type="primary">点击选择图片</el-button>
                          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件</div>
                        </el-upload>
                    </el-table-column>
                  </el-table>

二,在js里面添加函数接收上传的数据。

	imggreySuccess(file, row) {
      console.log(file);
      console.log(row);
    },
    
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值