Cordova creates the first app

Create your first app

This guide shows you how to create JS/HTML Cordova applications and publish them to different native mobile platforms by using the cordovacommand line interface (CLI). Cordova command line detailed reference view [CLI Reference].

Install Cordova CLI

Cordova command line tools are distributed as npm packages.

Install the cordovacommand line tool through these steps:

  1. Download and install Node.js . After installation, you can use node and  in the command line npm .

  2. (Optional) Download and install git client , if you don't have one. After the installation is successful, you can use it on the command line git. This command line is used to download resources in the git repository.

  3. Install the cordova module using Nodejs npmtools. cordovaThe module will be npmautomatically downloaded by the tool.

  • On OS X and Linux:

       $ sudo npm install -g cordova
    

    On OS X and Linux, the  npmcommands are prefixed sudobecause they cordovamay need to be installed in other restricted directories such as /usr/local/share. If you use the optional tool nvm/nave or have write access to the installation directory, then you can omit the sudoprefix. Here are more tips to  use when using  npm no  sudoprefix, if you want to do so.

  • On Windows:

       C:\>npm install -g cordova
    

-gThe sign tells  npm us to install globally  cordova. Otherwise we will install in a node_modulessubdirectory of the current working directory  .

After the installation is complete, you should be able to run cordovacommands on the command line, and some help information will be printed without any parameters.


Create App

Jump to the directory where you maintain the source code and create your cordova project:

$ cordova create hello com.example.hello HelloWorld

This will create the necessary directories for your cordova application. By default, the cordova createcommand generates the skeleton of a web-based application, and the home page of the project is a  www/index.html file.

Add platform

All subsequent commands need to be run in the project directory or any subdirectory of the project directory:

$ cd hello

Add the target platform to your App. We will add the'ios' and'android' platforms and make sure they are saved in config.xml:

$ cordova platform add ios --save
$ cordova platform add android --save

contact us

QQ: 250187715 
QQ group: 390736068


Guess you like

Origin blog.csdn.net/m0_37609394/article/details/79961712