[英]How to debug a cordova plugin with your phone?
I use Weinre to get a console from my phone. 我使用Weinre从手机上获取控制台。 But on Javascript errors with plugins (contacts, geolocalisation etc...) I get nothing....
但是关于插件的Javascript错误(联系人,地理定位等),我什么也没得到。
I don't know how to push on the console every javascript errors. 我不知道每个JavaScript错误如何在控制台上推送。
How to easily debug your javascript which use a plugin present only on your device ? 如何轻松调试仅使用设备上存在的插件的javascript?
Thank you. 谢谢。
You can use the Console Plugin to debug your code in iOS, android, windows phone, etc. 您可以使用控制台插件在iOS,Android,Windows Phone等中调试代码。
Install the plugin using: $ cordova plugin add org.apache.cordova.console
使用以下命令安装插件:
$ cordova plugin add org.apache.cordova.console
Then its as simple as using console.log(...);
然后就像使用
console.log(...);
in your javascript files. 在您的javascript文件中。
If you want to log your geolocation you can do: 如果要记录地理位置,可以执行以下操作:
var onSuccess = function(position) {
console.log(position.coords.latitude);
console.log(position.coords.longitude);
};
var onError = function(err) {
console.log(error.code);
console.log(error.message);
};
navigator.geolocation.getCurrentPosition(onSuccess, onError);
Then, when you build your app, and emulate, look for this log file in your project: 然后,在构建应用程序并进行仿真时,请在项目中查找以下日志文件:
.../platforms/ios/cordova/console.log
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.