el-upload禁用删除功能
时间: 2023-09-04 09:08:11 浏览: 257
要禁用 `el-upload` 组件的删除功能,你可以使用 `beforeRemove` 属性。这个属性需要传入一个函数,该函数会在删除文件之前被调用。如果这个函数返回 `false`,那么删除操作将被取消。
以下是一个禁用删除功能的示例:
```html
<el-upload
:before-remove="handleBeforeRemove"
:action="yourUploadUrl"
:on-success="handleSuccess"
>
<el-button slot="trigger" size="small" type="primary">上传文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
```
```javascript
methods: {
handleBeforeRemove(file, fileList) {
// 禁止删除操作
return false;
},
handleSuccess(response, file, fileList) {
// 处理上传成功后的逻辑
}
}
```
在上面的示例中,我们将 `beforeRemove` 属性设置为 `handleBeforeRemove` 方法,该方法返回 `false`,从而禁止了删除操作。同时,我们还设置了 `action` 属性和 `onSuccess` 方法来处理上传文件的逻辑。
阅读全文
相关推荐


















