10.Ionic CLI

http://ionicframework.com/docs/v2/cli/

Ionic CLI是开发Ionic App过程中使用的主要工具。它像一把瑞士军刀:它将各种各样的工具集成到一个单独的接口之下。CLI包含许多对Ionic开发来说至关重要的命令,如start,build,serve,和run。它还包括一些在某些情况下需要的命令如emulate和info等。

安装CLI

你首先需要安装node和npm,然后才能安装CLI。注意,请确保安装最新的Node。安装好后,运行下面的命令来安装Ionic CLI的最新版本:

npm install -g ionic

基本使用

最重要的命令之一是start,可以创建一个新的Ionic项目。试一下:

ionic start myAwesomeApp --v2

这将创建一个名为myAwesome的新App。然后cd到这个目录,运行下面的命令:

ionic info

这会输出Ionic环境的信息,这对调试来说是很有用的。最后,如果要在浏览器中查看你的App,你可以用serve命令:

ionic serve

下一步

现在你知道基本用法了,可以在左侧菜单继续查看其他的命令列表。如果你更喜欢使用命令行,可以简单的输入ionic来查看所有的命令列表。

(node:21652) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

 _ _
 (_) (_)
 _ ___ _ __ _ ___
 | |/ _ \| '_ \| |/ __|
 | | (_) | | | | | (__
 |_|\___/|_| |_|_|\___| CLI v2.1.0

Usage: ionic task args

=======================
Available tasks:
(use --help or -h for more info)

 start .......... Starts a new Ionic project in the specified PATH

 serve .......... Start a local development server for app dev/testing
 setup .......... Configure the project with a build tool (beta)
 generate ....... Generate pages and components
 platform ....... Add platform target for building an Ionic app
 run ............ Run an Ionic project on a connected device
 emulate ........ Emulate an Ionic project on a simulator or emulator
 build .......... Build (prepare + compile) an Ionic project for a given platform.
 plugin ......... Add a Cordova plugin
 resources ...... Automatically create icon and splash screen resources (beta)
 Put your images in the ./resources directory, named splash or icon.
 Accepted file types are .png, .ai, and .psd.
 Icons should be 192x192 px without rounded corners.
 Splashscreens should be 2208x2208 px, with the image centered in the middle.
 upload ......... Upload an app to your Ionic account
 share .......... Share an app with a client, co-worker, friend, or customer
 lib ............ Gets Ionic library version or updates the Ionic library
 io ............. Integrate your app with Ionic Cloud services
 security ....... Store your app's credentials for the Ionic Cloud
 push ........... Upload APNS and GCM credentials to Ionic Push
 package ........ Use Ionic Package to build your app
 config ......... Set configuration variables for your ionic app
 service ........ Add an Ionic service package and install any required plugins
 add ............ Add an Ion, bower component, or addon to the project
 remove ......... Remove an Ion, bower component, or addon from the project
 list ........... List Ions, bower components, or addons in the project
 info ........... List information about the users runtime environment
 help ........... Provides help for a certain command
 link ........... Sets your Ionic App ID for your project
 hooks .......... Manage your Ionic Cordova hooks
 state .......... Saves or restores state of your Ionic Application using the package.json file
 docs ........... Opens up the documentation for Ionic

results matching ""

    No results matching ""