pdf.worker.js找不到的错误

在这里插入图片描述
网上的资料一直都是更换版本

“vue-pdf”: “^4.2.0”,
“pdfjs-dist”: “^2.5.207”,

但是无效,一直找不到,
最终在下面的目录下新建一个es5文件夹,并将legacy中的三个文件夹内容复制过来。
在这里插入图片描述
在这里插入图片描述

process找不到怎么改
在这里插入图片描述
在public里面新建文件夹,然后新建PDFFile文件夹,里面放置PDF文件
在这里插入图片描述

在线帮助页面这样写
Help.vue

<template>
  <div class="d-flex-column h-100 ">
    <div class="pdfWrapper flex-grow-1">
      <pdf
          v-for="(i,index) in numPages"
          :src="pdfPath"
          :page="i"
          :key="index"
      ></pdf>
    </div>
  </div>
</template>
<script>
import pdf from 'vue-pdf'
import pdfPath from "../../public/PDFFile/PDFW_SampleBodyVisibility_2_3.pdf"

export default {
    
    
  name: "Help",
  components: {
    
    
    pdf
  },
  data() {
    
    
    return {
    
    
      currentPage: 1, // 页码
      pageCount: 5, // 总页数
      numPages: 1,
      pdfPath: pdfPath,
    }
  },
  mounted() {
    
    
    this.handelPdf()
  },
  methods: {
    
    
    async handelPdf() {
    
    
      this.numPages = await pdf.createLoadingTask(this.pdfPath).promise.then(pdf => {
    
    
        return pdf.numPages
      })
    },
  }
}
</script>
<style scoped>
.pdfWrapper {
    
    
  overflow: scroll;
}
</style>

一些错误的解决方法

https://www.jb51.net/article/261614.htm

猜你喜欢

转载自blog.csdn.net/Kerryliuyue/article/details/128388625