How to run uniapp with command
With the continuous development of mobile Internet, Hybrid applications are attracting more and more attention. Against this background, various new development frameworks have emerged. As a new hybrid development framework, Uniapp naturally attracts the attention of developers. Uniapp provides a way to quickly develop cross-platform applications, allowing developers to write code once and publish applications on multiple platforms, including iOS, Android, H5, etc. If you are not familiar with Uniapp yet, you can refer to the official website documentation first. This article will introduce how to run Uniapp using commands.
Uniapp CLI
Uniapp CLI is the command line tool for Uniapp. It provides a series of commands for building, running and debugging Uniapp applications. Through the Uniapp CLI, developers can develop and test applications locally and then package them for release to different platforms.
Install Uniapp CLI
Using Uniapp CLI requires installation first. Uniapp CLI supports global installation and local installation. Normally, we recommend using the Uniapp CLI through a global installation so that we can develop in any project folder.
The global installation command is as follows:
npm install -g @vue/cli
The local installation command is as follows:
npm install @vue/cli --save-dev
It should be noted that before using Uniapp CLI, make sure that the Node.js environment has been installed.
Create a project through Uniapp CLI
After installing Uniapp CLI, we can use it to create a new Uniapp project. Use the following command:
vue create -p dcloudio/uni-preset-vue my-project
Here, we are using a preset option, which is uni-preset-vue
. This refers to Uniapp’s official preset Vue template. By using this preset option, we can quickly create a Vue-based Uniapp project.
After entering this command, some configuration options will appear. Select the corresponding options to create a new Uniapp project.
Run the Uniapp project
After creating the new Uniapp project, we can run the project through the Uniapp CLI. Use the following command:
npm run dev:%PLATFORM%
where %PLATFORM%
refers to the corresponding target platform. This can be any of the following:
-
mp-weixin
: WeChat applet -
mp-alipay
: Alipay applet -
mp-baidu
: Baidu Mini Program -
mp-toutiao
: Toutiao Mini Program -
h5
: Web page operation
For example, to run the project on the WeChat applet, you can execute the following command:
npm run dev:mp-weixin
This command will start the development server and then open the corresponding address in the browser . The development server monitors file changes and recompiles the application and refreshes the browser page.
Package and publish the Uniapp project
After running the Uniapp project, we can package and publish the application. Use the following command:
npm run build:%PLATFORM%
Same as the run project command, where %PLATFORM%
refers to the target platform. Likewise, we must set the platform parameters to compile and push the application. For example, to create a production version of a WeChat applet, you can first package it with the following command:
npm run build:mp-weixin
This command will package the application into a production version of the WeChat applet and add the generated code and resource files Save to destination folder. We can upload the folder to the WeChat Mini Program Developer Platform to publish the application.
Summary
With the Uniapp CLI, we can use commands to run and build Uniapp applications. Through the above introduction, I hope readers can understand the basic usage of Uniapp CLI and be able to successfully use this tool to develop, test and publish Uniapp applications.
The above is the detailed content of How to run uniapp with command. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics









