在 vue 使用 el-upload 组件时,需要在上传一张图片后隐藏上传按钮
亲测可用,实现方式如下:
<el-row v-for="(item,index) in form" :key="index">
<el-upload
:class="{hideUpload:form[index].img_url != ''}"
:limit="1"
name="upload_img"
:file-list="form[index].img_url?[{name: 'upload_img', url: form[index].img_url}]:[]"
...
></el-upload>
</el-row>
<el-upload
:class="{hideUpload:updata.img_url != ''}"
:limit="1"
name="upload_img"
:file-list="updata.img_url?[{name: 'upload_img', url: updata.img_url}]:[]"
...
></el-upload>
...
<style lang="scss" scoped>
.hideUpload /deep/ .el-upload{
display:none; /* 上传按钮隐藏 */
}
/* 修改 el-upload 组件大小 */
/deep/ .el-upload{
width: 80px;
height: 80px;
line-height: 80px;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item{
width: 80px;
height: 80px;
line-height: 80px;
}
</style>
本文介绍了一种在Vue项目中使用el-upload组件时,如何实现在上传图片后自动隐藏上传按钮的方法。通过条件判断结合样式控制显示隐藏,确保用户交互体验的同时保持页面整洁。
4907

被折叠的 条评论
为什么被折叠?



