我是靠谱客的博主 完美柜子,这篇文章主要介绍Vue - el-upload 组件在 on-success 文件上传成功的钩子中传递更多参数,现在分享给大家,希望可以做个参考。

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

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

解决方法:

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

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<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>
复制代码
1
2
3
4
5
6
// 文件上传成功时的钩子 handleSuccess(response, file, fileList, rowInfo) { console.log(response, file, fileList, rowInfo); },

最后

以上就是完美柜子最近收集整理的关于Vue - el-upload 组件在 on-success 文件上传成功的钩子中传递更多参数的全部内容,更多相关Vue内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部