ElementUI Upload 上传官网:https://element.eleme.cn/#/zh-CN/component/upload

ElementUI官网中upload组件的on-success的钩子中,只能传递 response, file, fileList 这三个参数,如果想要传递更多的参数该怎么解决?

解决方法:

on-success 绑定一个定义在 methods 中的方法,调用一个匿名函数,将需要用到的信息参数传递进去。然后在匿名函数内部中,再通过返回值调用一个函数的形式,将信息参数传递过去。

<el-table-column
  label="附件"
  align="center"
  show-overflow-tooltip
>
  <template slot-scope="scope">
    <el-upload
      :action="baseUrl"
      :headers="config"
      :file-list="fileList"
      :on-success="
        (response, file, fileList) => {
          return handleSuccess(response, file, fileList, scope.row);
        }
      "
    >
      <el-button type="text">点击上传</el-button>
    </el-upload>
  </template>
</el-table-column>
// 文件上传成功时的钩子
handleSuccess(response, file, fileList, rowInfo) {
  console.log(response, file, fileList, rowInfo);
},
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐