el-upload上传时如何拿到文件
时间: 2023-08-30 12:09:16 浏览: 187
在el-upload组件中,可以通过监听on-change事件来获取上传的文件。在on-change事件的回调函数中,可以通过event.target.files来获取上传的文件列表。具体代码如下所示:
```javascript
<el-upload :action="upUrl" :on-change="handleChange">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
...
methods: {
handleChange(event) {
const fileList = event.target.files;
// 处理上传的文件
// ...
}
}
```
通过event.target.files可以获取到上传的文件列表,然后可以对文件进行处理。
#### 引用[.reference_title]
- *1* [el-upload多文件上传;el-upload采用递归依次上传文件;el-upload采用递归在上一个文件上传成功后再传下一...](https://blog.csdn.net/i_am_a_div/article/details/127431603)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [el-upload 上传文件之后 实现文件流下载](https://blog.csdn.net/callBack_____/article/details/125215143)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。](https://blog.csdn.net/i_am_a_div/article/details/125545564)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文