项目场景:

使用vue-pdf组件实现文件预览功能


问题描述:

安装依赖后报错vue-pdf Cannot read properties of undefined (reading 'catch')
TypeError: Cannot read properties of undefined (reading 'catch')
    at PDFJSWrapper.renderPage (pdfjsWrapper.js?a068:196)
    at VueComponent.resize (componentFactory.js?0d60:75)
    at invokeWithErrorHandling (vue.esm.js?a026:1872)
    at VueComponent.invoker (vue.esm.js?a026:2197)
    at invokeWithErrorHandling (vue.esm.js?a026:1872)
    at VueComponent.Vue.$emit (vue.esm.js?a026:3912)
    at VueComponent.handler (resize-sensor.vue?c7ed:49)
    at invokeWithErrorHandling (vue.esm.js?a026:1872)
    at Watcher.run (vue.esm.js?a026:4593)
    at flushSchedulerQueue (vue.esm.js?a026:4335)

解决方案:

看了很多方法,最后锁定依赖版本解决报错问题。

①在根目录下输入一下命令

npm i pdfjs-dist@2.5.207
npm i vue-pdf@4.2.0

②修改pacakge.json文件

"pdfjs-dist": "2.5.207",
"vue-pdf": "4.2.0"

修改完重新启动项目,就没有再出现报错问题了。

附原文参考链接:https://www.cnblogs.com/thinkingthigh/p/15661288.html

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐