vue-pdf组件多次切换文件进行预览会出现白屏,但是对应的页码正确,就是没有文字
<pdf v-for="(i,index) in currentNum" :key="i" :src="pdfSrc" :page="i" style="width: 100%" ref="waybillRef"></pdf>
//pdf加载
let blob = window.URL.createObjectURL(
new Blob([res.data], {
type: 'application/pdf;charset=UTF-8',
})
);
this.pdfSrc = pdf.createLoadingTask(blob);
this.pdfSrc.promise.then(pdf => {
this.pageNum = pdf.numPages
console.log(this.pageNum)
// 用个定时器解决报错Rendering cancelled
var timer = setInterval(() => {
this.currentNum += 1
if (this.currentNum === this.pageNum) {
clearInterval(timer)
}
}, 500)
}) .catch(err => {
console.error('pdf 加载失败', err)
})