el-upload点击时间在哪
时间: 2023-10-14 11:25:33 浏览: 103
elemetUi 组件--el-upload实现上传Excel文件的实例
5星 · 资源好评率100%
el-upload 组件的点击时间可以在以下两种情况下触发:
1. 点击上传按钮触发:这个点击事件可以在 el-upload 组件的 `before-upload` 属性中进行配置,例如:
```html
<el-upload
class="upload-demo"
action="/upload"
:before-upload="handleBeforeUpload"
>
<el-button slot="trigger" type="primary">选取文件</el-button>
<el-button type="success" class="upload-demo-start" :disabled="!uploadDisabled">开始上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
```
```javascript
methods: {
handleBeforeUpload(file) {
console.log('点击上传按钮触发', file);
}
}
```
2. 选择文件后触发:这个点击事件可以在 el-upload 组件的 `on-change` 属性中进行配置,例如:
```html
<el-upload
class="upload-demo"
action="/upload"
:on-change="handleChange"
>
<el-button slot="trigger" type="primary">选取文件</el-button>
<el-button type="success" class="upload-demo-start" :disabled="!uploadDisabled">开始上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
```
```javascript
methods: {
handleChange(file, fileList) {
console.log('选择文件后触发', file, fileList);
}
}
```
阅读全文