vue-pdf icon indicating copy to clipboard operation
vue-pdf copied to clipboard

Cannot read property 'catch' of undefined

Open Gourdbaby opened this issue 3 years ago • 21 comments

I get an error in the browser when I was using Vue-pdf. The error information

TypeError: Cannot read property 'catch' of undefined
    at PDFJSWrapper.renderPage (new.web.c42b3b.js:formatted:72084)
    at a.resize (new.web.c42b3b.js:formatted:36592)
    at Ht (vendors.web.bebfbe.js:1)
    at a.n (vendors.web.bebfbe.js:1)
    at Ht (vendors.web.bebfbe.js:1)
    at a.t.$emit (vendors.web.bebfbe.js:1)
    at a.handler (new.web.c42b3b.js:formatted:36474)
    at Ht (vendors.web.bebfbe.js:1)
    at dn.run (vendors.web.bebfbe.js:1)
    at hn (vendors.web.bebfbe.js:1)

but, This error isn't caught in the local environment. My code

import pdf from 'vue-pdf/src/vuePdfNoSssNoWorker'
import 'pdfjs-dist/build/pdf.worker.entry.js'

<pdf :src="resumeUrl" v-for="i in pdfPageCountNum" :key="i" :page="i" ></pdf>

Vue-pdf version

"vue-pdf": "^4.0.12",

Gourdbaby avatar Jun 21 '21 02:06 Gourdbaby

我也出现你这种情况了,我把版本降到4.0.0 就不会出现这个 Cannot read property 'catch' of undefined 问题了

sztblogs avatar Jun 21 '21 05:06 sztblogs

@sztblogs 谢谢 我试试

Gourdbaby avatar Jun 21 '21 05:06 Gourdbaby

@sztblogs 不行 4.0.0不知道怎么找不带worker的版本,我不能带worker的,带worker在生产环境跨域

Gourdbaby avatar Jun 21 '21 05:06 Gourdbaby

Same error occured to me. Thanks to @sztblogs I decreased version to 4.0.0 and it works

E1mir avatar Jun 21 '21 09:06 E1mir

可以参照这个回答 安装2.7版本的pdfjs-dist https://github.com/FranckFreiburger/vue-pdf/issues/314 我安装后 这个报错消失了

qq9694526 avatar Jun 21 '21 09:06 qq9694526

@qq9694526 我这里指定pdfjs-dist版本 在本地环境没问题,在预上线环境报错

new:1 Uncaught (in promise) n {message: "The API version \"2.6.347\" does not match the Worker version \"2.5.207\".", name: "n", details: "[object Object]"}

Gourdbaby avatar Jun 22 '21 02:06 Gourdbaby

我在生产环境试了一下 没有出现你讲的这种问题 你看一下是不是别的地方影响的

sztblogs avatar Jun 22 '21 03:06 sztblogs

可以参照这个回答 安装2.7版本的pdfjs-dist #314 我安装后 这个报错消失了

[email protected] 版本

qq9694526 avatar Jun 22 '21 07:06 qq9694526

我也是,之前出现你这个问题了,然后降到4.0.0就行了。

nolandcheng avatar Jun 22 '21 07:06 nolandcheng

Same issue...

baeteja avatar Jun 22 '21 16:06 baeteja

亲测~4.2.0可以

zyp1573 avatar Jun 23 '21 10:06 zyp1573

"pdfjs-dist": "^2.5.207", "vue-pdf": "^4.2.0" 亲测可以解决

re-doc avatar Jun 29 '21 07:06 re-doc

"pdfjs-dist": "^2.5.207", "vue-pdf": "^4.2.0" 亲测可以解决

4.2.0和4.0.0都不能解决

sailyw avatar Jul 09 '21 06:07 sailyw

"pdfjs-dist": "^2.5.207",
"vue-pdf": "^4.0.12",

After a lot of trial and error this is the only thing that worked for me.

ramonakira avatar Jul 19 '21 14:07 ramonakira

Reverting to an older version is not a solution, it's more like a workaround.

@Gourdbaby Does the issue affect the user experience or it's just a console error?

dvago avatar Jul 27 '21 10:07 dvago

package-lock.json 里面直接锁定到4.0.0版本 "vue-pdf": "4.0.0",

snow-49 avatar Aug 04 '21 04:08 snow-49

package-lock.json 里面直接锁定到4.0.0版本 "vue-pdf": "4.0.0",

这才是正解,我发现虽然你安装的时候指定的是4.0.0的版本npm i [email protected],但是实际上node_modules中安装的还是最新版,删除package-lock.json重新装也不行,只有在package-lock.json中锁定4.0.0的版本才解决

tohere avatar Aug 06 '21 06:08 tohere

"pdfjs-dist": "2.5.207", "vue-pdf": "4.2.0" 锁定这两个版本完美解决

chenxu1112 avatar Aug 26 '21 10:08 chenxu1112

Same Issue on 4.3.0, but only on iOS / iPadOS Devices.

ssgnoe avatar Feb 28 '22 10:02 ssgnoe

I had the same issue, resolved it by downgrading

"vue-pdf": "^4.0.0", "pdfjs-dist": "^2.5.207",

and did npm clean-install

Thanks for leads

CourageT avatar Jul 01 '22 11:07 CourageT