downloadFile(index,row){
this.loadingOverLay=this.$loading({
lock:true,
text:'文件生成中',
spinner:'el-icon-loading'
});
let eleIF=document.createElement('iframe')
elemIF.src=process.env.VUE_APP_BASE_API+'/ufmgt/attachment/downloadFile?id='+row.id+'&submissionId='+row.submissionId+'&deptId='+row.deptId;
elemIF.style.display='none',
document.body.appendchild(elemIF);
this.loadingOverLay.close()
}
然后我的下载路由api是
export function downloadFile(query) {
return request({
url: '/ufmgt/attachment/downloadFile?id='+'&submissionId='+'&deptId=',
method: 'get',
params: query,
})
}
那应该是let fileName=row.tFileName;出问题了,console.log(row)一下看看这个row对象是不是undefined,或者这个row对象里边有没有tFileName属性。
你是代码没贴全吗?我没看到你在哪儿调用downloadFile(query)呀?
另外,downloadFile(query)应该是一个异步函数吧?你的downloadFile(index,row)中的内容应该在downloadFile(query)完成后进行。。。要不然肯定下载不到。
downloadFile(index,row){
let fileName=row.tFileName;
//var url=window.URL.createObjectURL(blob);
let url=process.env.VUE_APP_BASE_API+'/ufmgt/attachment/downloadFile?id='+row.id+'&submissionId='+row.submissionId+'&deptId='+row.deptId;
let a = document.createElement('a')
a.href = url
a.target = '_blank'
a.style.display = 'none'
a.setAttribute('downloadFile',fileName+fileType)
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
window.URL.revokeObjectURL(url)
},
我这样写,控制台说"TypeError: Cannot read properties of undefined (reading 'tFileName')"
那我应该改哪里呢