Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading '_android') #292

Open
Cyclodex opened this issue Mar 16, 2023 · 9 comments
Open

Cannot read properties of undefined (reading '_android') #292

Cyclodex opened this issue Mar 16, 2023 · 9 comments

Comments

@Cyclodex
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

My issue was, after updating to Vue 2.7.13 and @vue/cli 5.0.8 the generated JS code throws an error, because "this" is undefined when running this line:
if (this._android && this._android <= 2.1) {

I think its related to js modules and this is always undefined on global level.

image

Here is the diff that solved my problem:

diff --git a/node_modules/qrcode-js-package/qrcode.js b/node_modules/qrcode-js-package/qrcode.js
index f89e602..d5e5bd9 100644
--- a/node_modules/qrcode-js-package/qrcode.js
+++ b/node_modules/qrcode-js-package/qrcode.js
@@ -281,7 +281,7 @@ var QRCode;
 		
 		// Android 2.1 bug workaround
 		// http://code.google.com/p/android/issues/detail?id=5141
-		if (this._android && this._android <= 2.1) {
+		if (this && this._android && this._android <= 2.1) {
 	    	var factor = 1 / window.devicePixelRatio;
 	        var drawImage = CanvasRenderingContext2D.prototype.drawImage; 
 	    	CanvasRenderingContext2D.prototype.drawImage = function (image, sx, sy, sw, sh, dx, dy, dw, dh) {

This issue body was partially generated by patch-package.

@Sun-hai-yang
Copy link

Have you solved this problem yet?

@Cyclodex
Copy link
Author

Cyclodex commented Mar 21, 2023

@Sun-hai-yang What do you mean exactly? The problem can be fixed with the above "patch".

Do you need to know how you can apply it to your own codebase?

@IvanVZabrodin
Copy link

For me it still gives the same issue, even after the fix

@hotdogc1017
Copy link

I have the same problem as you🥲

@hotdogc1017
Copy link

I have found a solution! Replace 'qrcodejs2' with 'qrcodejs2-fix`

in package.json:
"qrcodejs2": "^0.0.2", // remove
"qrcodejs2-fix": "^0.0.1", // add

@hotdogc1017
Copy link

I have found a solution! Replace 'qrcodejs2' with 'qrcodejs2-fix`

in package.json: "qrcodejs2": "^0.0.2", // remove "qrcodejs2-fix": "^0.0.1", // add

I have checked the source code of the error location and the solution is consistent with @Cyclodex proposed method

@Minori-ty
Copy link

the same problem

@P2K0
Copy link

P2K0 commented Sep 29, 2024

the same problem

@lanyangyang1999
Copy link

thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants