
上传之后,右边的这个框就隐藏
在el-upload标签上添加一个::class="{ hide: hideUpload_introduce }",动态的class
data里面
hideUpload_introduce: false,
limitCount: 1,
同时在el-upload上的两个钩子添加事件:on-change=“handleIntroduceUploadHide”,注意,如果我们要删除照片,删除之后,是希望上传框出现的,所以还要:on-remove=“handleIntroduceRemove”,在删除时触发事件,显示上传框
methods里面
handleIntroduceUploadHide(file, fileList) {
this.ruleForm.hideUpload_introduce =
fileList.length >= this.ruleForm.limitCount;
},
handleIntroduceRemove(file, fileList) {
this.ruleForm.hideUpload_introduce =
fileList.length >= this.ruleForm.limitCount;
},
style 里面
/deep/.hide .el-upload--picture-card {
display: none;
}
动态上传限制与隐藏:前端文件上传管理策略
本文介绍如何在前端使用El-upload组件实现图片上传数量限制,并通过on-change和on-remove事件管理隐藏上传框。通过data中hideUpload_introduce属性和方法中的处理函数,当文件数量达到限制时隐藏上传框,删除文件后重新显示。
2603

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



