vue-pdf Error in v-on handler: “TypeError: Cannot read propertie

时间:2025-02-18 09:48:46

vue-pdf Error in v-on handler: “TypeError: Cannot read properties of undefined (reading ‘catch’)”

problem

使用vue-pdf解析pdf文件,控制台出现报错
从traceback 看vue组件 -> vud-pdf -> vue-resize-sensor 导致

vue.esm.js:5136 [Vue warn]: Error in v-on handler: "TypeError: Cannot read properties of undefined (reading 'catch')"

found in

---> <ResizeSensor> at node_modules/vue-resize-sensor/src/resize-sensor.vue
       <Pdf> at node_modules/vue-pdf/src/vuePdfNoSss.vue
         <App> at src/components/test/index.vue
           <Home> at src/views/Home.vue

reason

原因:到底哪里出错了不清楚,可能是vue版本和vue-pef版本不兼容导致

solution

网上找到的方案,亲测可用
调整vue-pdf版本

  • 调整前版本:“^4.3.0”,
  • 调整后版本:“4.2.0”,

具体指令:
yarn remove vue-pdf
yarn add vue-pdf@4.2.0
yarn add pdfjs-dist@2.5.207