使用pdf.js,点击预览显示的不是需要的文件,而是网址首页,这是什么问题?

axios({
url: this.adress + '/index/download',
headers: this.myHeaders, // 请求头
method: 'get',
params: this.downloadA,
responseType: 'blob'
})
.then(res => {
const binaryData = []
binaryData.push(res)
const url = window.URL.createObjectURL(new Blob(binaryData, { type: 'application/pdf' }))
this.pdfUrl = './static/pdf/web/viewer.html?file=' + encodeURIComponent(url)
this.dialogVisible = true
})

浏览器 f12 抓包看下,你请求的是不是 pdf 的地址,服务器是否返回了什么错误信息,比如没有权限、文件找不到之类。

如果你的请求地址吗,没有问题,你可以查一下是不是你的服务端程序有拦截的代码,不允许你的这个请求