通常上传完图片会把本地fileList中的url替换成图片服务器的url,在替换过程中没有唯一标识,则造成了这种闪屏情况。
改之前代码
let fd = new FormData()fd.append('file', file)fd.append('path', 'goods')let { data } = await uploadImage(fd) this.fileList.push({name: file.name,url: data.url})
改之后代码
let fd = new FormData()fd.append('file', file)fd.append('path', 'goods')let { data } = await uploadImage(fd)this.fileList.push({name: file.name,uid: file.uid, //带上上传前的uid作为标识url: data.url,deletable: true,imageFit: 'contain',previewSize: 80,})
改之后效果
这样就解决了问题,提高了用户体验!