场景:使用upload组件,调用后端上传图片接口,将接口返回的图片路径放到 el-image 中实现回显
问题:在开发环境调试过程中,图片可正常回显。代码部署到线上环境服务器后,上传成功,返回的图片路径在浏览器可正常打开,但就是无法回显图片
代码:
父组件代码
<imgUpload :size="1024*5" :fileList="TData.fileList" />
<script setup lang="ts">
import imgUpload from '../components/imgUpload/index.vue'
const TData=reactive({
fileList:[] as any[],
})
async function httpRequest(v:any){
const newForm = new FormData()
newForm.append('file',v.file)
const {data,code} = await oosImgUpload(newForm)
if(code==200){
ElMessage({
type:"success",
message:'上传成功'
})
const {ossId,fileName,url,prefixPath} = data
cooperateFormData.feiles.push({
"photoFile":url+"\\"+fileName,
"ossId":ossId,