The page on the phone is not as easy to debug as desktop development. You can use weinre for remote debugging to facilitate development. This article describes installation and use under Windows.
Installation
With NPM installation, you can run:
NPM install-g weinre
The installation path may be like this:
Input command
Weinre
Can be started.
To open a URL using your browser:
http://localhost:8080
We recommend using Chrome.
If you have a firewall, be aware that you need to allow 8080 port data to pass.
You can now connect the Cordova program for debugging. Put the following code in the index.html.
<script src="http://你的pc的ip:8080/target/target-script-min.js"></script>
If you use an emulator, you can set the IP to localhost. Except for Android emulator, you need to set the IP to 10.0.2.2.
If you are using a physical device, it is a bit more complicated to make sure that the physical device can connect to the computer. My computer and mobile phone use the same network, more easy to connect.
It is not necessary to remove the debug code before putting into production environment. Otherwise the app will die easily.
Now open the Cordova app
Open link
Test:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Development Series ten Cordova Architecture Learning weinre Remote Debugging technology