Closed yaya8023 closed 5 years ago
测试平台:ios 框架版本:ionic 4.7 可以控制台打印回调参数的值,但是当我想把它赋值给一个变量,或者在这个回调方法里面做一些赋值,或者http请求的操作就报错了。 demo代码: Wechat.isInstalled(function (installed) { try { if(installed) { console.log(111);
this.isWechatInstalled = "true"; } else { console.log(222); this.isWechatInstalled = "false"; } } catch (err) { console.log(333); } }, function (error) { console.error(error) });
控制台打印了: 111 333
xcode报错信息: Error in Success callbackId: Wechat945865541 : TypeError: null is not an object
ERROR: Unhandled Promise rejection: null is not an object (evaluating '') ; Zone: ; Task: Promise.then ; Value: TypeError: null is not an object (evaluating '') ionic://localhost/main-es2015.js:2793:17 callbackFromNative@ionic://localhost/cordova.js:288:63 ionic://localhost/plugins/cordova-plugin-ionic-webview/src/www/ios/ios-wkwebview-exec.js:129:35 run@ionic://localhost/polyfills-es2015.js:15106:49 ionic://localhost/polyfills-es2015.js:15837:39 runTask@ionic://localhost/polyfills-es2015.js:15150:57 drainMicroTaskQueue@ionic://localhost/polyfills-es2015.js:15541:42 promiseReactionJob@[native code]
请问this.isWechatInstalled = "true";这一步为什么走不了?
同样的auth登录方法,获取到了res.code,可以打印出来,但是我传到http.post请求的参数里面,就不行,报同样的错误。 @xu-li
已解决。与插件无关。在wechat方法外var that = this;方法内部用that代替this调用本地变量或者方法。
测试平台:ios 框架版本:ionic 4.7 可以控制台打印回调参数的值,但是当我想把它赋值给一个变量,或者在这个回调方法里面做一些赋值,或者http请求的操作就报错了。 demo代码: Wechat.isInstalled(function (installed) { try { if(installed) { console.log(111);
控制台打印了: 111 333
xcode报错信息: Error in Success callbackId: Wechat945865541 : TypeError: null is not an object
ERROR: Unhandled Promise rejection: null is not an object (evaluating '') ; Zone: ; Task: Promise.then ; Value: TypeError: null is not an object (evaluating '') ionic://localhost/main-es2015.js:2793:17
callbackFromNative@ionic://localhost/cordova.js:288:63
ionic://localhost/plugins/cordova-plugin-ionic-webview/src/www/ios/ios-wkwebview-exec.js:129:35
run@ionic://localhost/polyfills-es2015.js:15106:49
ionic://localhost/polyfills-es2015.js:15837:39
runTask@ionic://localhost/polyfills-es2015.js:15150:57
drainMicroTaskQueue@ionic://localhost/polyfills-es2015.js:15541:42
promiseReactionJob@[native code]
请问this.isWechatInstalled = "true";这一步为什么走不了?
同样的auth登录方法,获取到了res.code,可以打印出来,但是我传到http.post请求的参数里面,就不行,报同样的错误。 @xu-li