element upload组件 多文件上传闪一下及开启多选后onSuccess回调一次的问题
多图片卡片类型展示,上传闪一下问题
是因为组件会渲染ready状态的文件,最简单的就是隐藏
// An highlighted block//最简单粗暴解决方案:/deep/.el-upload-list__item.is-ready{display:none;}开启多选文件后,成功回调一次的问题
多选上传时 只要赋值onSuccess就只会触发一次 解决方案等本次所有的都成功后再赋值
onSuccess(response,file,fileList){if(response.code!=200){this.onRemove(file);returnthis.$message.error(response.message);}constnewUrl=response.url;if(this.isStringMode){// 单文件模式:直接返回 URL 字符串this.$emit("input",newUrl);}else{// 多选上传时 只要赋值onSuccess就只会触发一次 解决方案为所有的都成功后再赋值if(fileList.every(item=>item.status=='success')){// 找到新上传成功的数据 合并letnewUrls=fileList.filter(item=>item.response).map(item=>item.response.url);consturls=[...(this.value||[]),...newUrls];this.$emit("input",urls);}}},