在模擬器或手機上執行 Ionic App
1.新增平臺目標
iOS 版:
$ ionic platform add ios
安卓:
$ ionic platform add android
Windows:
$ ionic platform add windows
2.構建你的應用程式
iOS 版:
$ ionic build ios
安卓:
$ ionic build android
Windows:
$ ionic build windows
開發期間的 Live Reload App(測試版)
run
或 emulate
命令會將應用程式部署到指定的平臺裝置/模擬器。你還可以通過新增 --livereload
選項在指定的平臺裝置上執行實時重新載入。實時重新載入功能類似於 ionic serve
,但不是使用標準瀏覽器開發和除錯應用程式,編譯的混合應用程式本身正在監視其檔案的任何更改並在需要時重新載入應用程式。這減少了為小變化不斷重建應用程式的要求。但是,對外掛的任何更改仍然需要完全重建。要使實時重新載入工作,開發機器和裝置必須位於同一本地網路上,並且裝置必須支援 Web 套接字 。
啟用實時重新載入後,還可以通過包含 --consolelogs
或 -c
選項將應用程式的控制檯日誌列印到終端/命令提示符。此外,可以使用 --serverlogs
或 -s
選項列印開發伺服器的請求日誌。
run
和 emulate
的命令列標誌/選項
[--livereload|-l] ....... Live Reload app dev files from the device (beta)
[--consolelogs|-c] ...... Print app console logs to Ionic CLI (live reload req.)
[--serverlogs|-s] ....... Print dev server logs to Ionic CLI (live reload req.)
[--port|-p] ............. Dev server HTTP port (8100 default, live reload req.)
[--livereload-port|-i] .. Live Reload port (35729 default, live reload req.)
[--debug|--release]
在伺服器執行以進行實時重新載入時,你可以在 CLI 中使用以下命令:
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
3.模擬你的應用程式
在指定的平臺模擬器上部署 Ionic 應用程式。這只是 run --emulator
的別名。
iOS 版:
$ ionic emulate ios [options]
安卓:
$ ionic emulate android [options]
Windows:
$ ionic emulate windows [options]
在 AVD 或移動裝置中模擬應用程式期間,你可以在 Chrome 瀏覽器中檢查該應用程式。在 Chrome 瀏覽器的位址列中鍵入以下命令。
chrome://inspect/#devices
4.執行你的應用程式
在指定的平臺裝置上部署 Ionic 應用程式。如果找不到裝置,它將部署到模擬器/模擬器。
iOS 版:
$ ionic run ios [options]
安卓:
$ ionic run android [options]
Windows:
$ ionic run windows [options]
4.1。指定目標
$ ionic run [ios/android/windows] --target="[target-name]"
你可以檢查執行 $ adb devices
的裝置/模擬器的目標名稱。