Ionic v3在真实设备上实时重载

时间:2018-02-25 23:19:57

标签: cordova ionic3 cordova-plugins livereload

是否可以在实际的Android设备上进行实时重新加载。目前ionic cordova run android -l为我的设备提供了一个用于实时重新加载的Web服务器端口,但它将其视为浏览器与本机应用程序。因此,像window.pluginswindow.cordova这样的项目不会加载到服务器/浏览器的实时重载中,这会让我不断头疼。

我喜欢实时重新加载的快速开发功能,但没有window.pluginswindow.cordova我的应用程序的许多方面都在破碎 - 我使用了很多独立的插件,而不是离子原生的。

感谢。

1 个答案:

答案 0 :(得分:2)

我在另一个论坛上找到了解决方案。基本上,您必须将cordova.js文件复制到根项目/www文件夹中。

3. Make cordova and plugins available
Copy the following from the viewer app’s platforms/ios/platform_www on the mac:
cordova_plugins.js, cordova.js + the two folders cordova-js-src and plugins and paste them into your www folder on the developement machine.

Thats it. Now you can do this ionic serve on your developement machine:
ionic serve -a -b -s -c -l --platform ios --nocordovamock

Then start the viewer app on your mac (or device). It should now load your project and automatically update when you save any changes.

When you are ready to publish your app you have to remove the cordova_plugins.js, cordova.js + the two folders cordova-js-src and plugins in your www folder before the final build.

原始版还有一些细节 - 对于日志记录和其他用户输入:https://forum.ionicframework.com/t/ionic-how-to-livereload-on-ios-and-android/50222