kra*_*r65 37 javascript logging cordova console.log ionic-framework
我正在使用Ionic框架构建一个应用程序,到目前为止我已经在浏览器中完成了.因为我现在想使用cordovaOauth插件,我需要使用模拟器.问题是我无法像在浏览器中那样在模拟器中看到任何console.log(),这使得调试变得困难.
有人知道在Ionic/Cordova中我如何在模拟器中使用控制台日志记录?欢迎所有提示!
Car*_*ona 49
只需在模拟器中启用控制台日志即可.这是我的例子:
> ionic emulate ios --livereload
Setup Live Reload
Running dev server: http://localhost:8100
Adding in default Ionic hooks
Running live reload server: http://localhost:35729
Watching : [ 'www/**/*', '!www/lib/**/*' ]
Ionic server commands, enter:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit
Run Code Online (Sandbox Code Playgroud)
键入consolelogs的命令行并回车.
consolelogs
Console log output: enabled
Loading: /?restart=382451
ionic $ 0 498458 log Hi there! This is from console.log
Run Code Online (Sandbox Code Playgroud)
Yar*_* U. 28
跑 ionic emulate ios -l -c
这将打开具有livereload功能的模拟器,您将在终端中看到所有控制台日志.在离子服务器运行时,关闭(或打开)控制台日志只是写入consolelogs或仅c在终端中
使用iOS模拟器/设备时调试应用程序的另一种非常方便的方法是使用Safari开发人员工具
当应用程序运行时 - 进入Safari并选择"开发> iOS模拟器>您的页面"
如果您使用真实设备,您将看到设备的名称,而不是"iOS模拟器"
如果您在Safari中没有看到"开发"菜单 - 请输入Safari的首选项并从"高级"选项卡启用它
S.T*_*ane 19
如果你不想在模拟器/模拟器中使用控制台日志
ionic emulate -l -c <PLATFORM>
如果您在设备中进行测试时不想观看控制台日志,则可以启动以下命令:
ionic run -l -c <PLATFORM>
-c = --consolelogs:将应用程序控制台日志打印到Ionic CLI(livereload req.)
-l = --livereload:从设备重新加载app dev文件
可以帮助别人!
如果您使用运行Android 4.4或更高版本的设备测试您的网络应用程序,则可以使用Chrome开发者工具在WebView中远程调试您的网页.只需打开chrome://在桌面上检查连接USB调试模式的手机.
有几种方法可以调试您的离子应用程序.
以下是添加插件的方法:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
希望这可以帮助!当我调试GeoFire错误并测试cordova相机和地理位置api时,它对我来说非常方便.
在 Ionic 3 上,您可以通过
ionic cordova run android --emulator -l -c
Run Code Online (Sandbox Code Playgroud)
根据您的要求替换android为ios。更多信息在这里:https : //ionicframework.com/docs/cli/cordova/run/
| 归档时间: |
|
| 查看次数: |
46596 次 |
| 最近记录: |