vue-pdf组件报错vue-pdf Cannot read properties of undefined (reading ‘catch‘)

项目场景:

使用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 [email protected]
npm i [email protected]

②修改pacakge.json文件

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

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

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

你可能感兴趣的:(Vue.js,vue.js,前端)