Element UI 上传一张图片后隐藏上传按钮
el-upload里面绑定一个占位class:
:class="{hide:hideUpload}"
data里面初始化:
hideUpload: false,
limitCount:1
onChange 事件里面(添加文件、上传成功和上传失败时都会被调用的那个):
onChange(file, fileList) {
this.hideUpload = fileList.length >= this.limitCount;
},
handleRemove 事件里面(删除文件被调用的那个):
handleRemove(file, fileList) {
this.hideUpload = fileList.length >= this.limitCount;
},
style 样式里面,把scoped去掉(或者外部引入样式文件,目的都是为了修改element-ui自带的样式)
<style>
.hide .el-upload--picture-card {
display: none;
}
</style>
https://github.com/ElemeFE/element/issues/3367#issuecomment-376402380