Teach you how to create a project using vue-cli3 in five minutes (beginner's guide)

Teach you how to create a project using vue-cli3 in five minutes (beginner's guide)

1. Build the Vue environment

Install Nodejs Download Nodejs from the official website. If you want a stable development environment, download the LTS (Long Time Support) version, which is stable.

Click me to enter the node official website

After installation, enter node -v in cmd to check whether the installation is successful. If the version number appears as shown below, it is successful.

insert image description here

2. Vue Scaffolding Tools

Install vue-cli globally and enter in the command line:

npm install --g vue-cli

Using the official image of npm directly in China is very slow. It is recommended to use Taobao image or yarn

The installation of Taobao mirror is as follows

npm install -g cnpm --registry=https://registry.npm.taobao.org
//After successful installation, use cnpm i xxx instead of npm install xxx

3. Create a project

vue create project name
vue create code //where code is the name of your project directory (press enter to confirm and proceed to the next step)

At the beginning, the following two items will appear when you press Enter

insert image description here

Default (Vue 3) ([Vue 3] babel, eslint) (The default configuration provides babel or eslint support)
Manually select features

We can use the up and down keys and the space bar to select what we need. Generally, we will choose manual configuration.

4. Select manually select (press enter to confirm and proceed to the next step)

insert image description here

Wang briefly described the function of each item:

  • Babel mainly converts es6 syntax into compatible js (select)
  • TypeScript supports writing code using TypeScript syntax
  • Progressive Web App (PWA) Support [Make web pages more like native apps]
  • Router supports vue routing configuration plug-in (usually selected)
  • Vuex supports vue program state management mode (generally selected)
  • CSS Pre-processors supports CSS pre-processors (usually selected)
  • Linter / Formatter supports code style checking and formatting (selected)
  • Unit Testing
  • E2E Testing

Common project selections are as follows

insert image description here

5. After completing the selection, press Enter. Here we choose 3.x

insert image description here

6. After completion, press Enter to display the following interface

insert image description here

What this means is to ask you whether this project uses history mode. If you choose Y, you need to configure the background. Please refer to the vueRouter official website for details. Here we choose n

7. Press Enter to display the following interface

insert image description here

What this means is to ask you which CSS preprocessing language to choose. I generally use SCSS in my project. I choose the first one.

8. Press Enter to display the following interface

insert image description here

What this means is to choose a way to format the code: I usually choose ESLint + Prettier

9. Press Enter to display the following interface

insert image description here

What this means is to ask you when to perform code rule detection. I usually choose to detect on save, that is, Lint on Save

10. Press Enter to display the following interface

insert image description here

Here we mean where to put the configuration files for Babel, PostCSS, ESLint. Usually we choose to put them in a separate location to make the package.json file cleaner, so choose the first one.

11. Press Enter to display the following interface

insert image description here

Here you will be asked whether to record this configuration selection. After selecting, you will be asked to give this configuration a name so that you can quickly configure the selection next time. Finally, press Enter to initialize the project. After completion, it will be as shown below:

insert image description here

12. Start the project according to the prompts

According to the instructions, we first execute cd code, then execute npm run serve

insert image description here

insert image description here

13. When we need to customize webpack related configurations, we need to create a vue.config.js file in the project root directory. It will be automatically loaded by @vue/cli-server. The official website will provide detailed configuration content. You can go to the official website to check it out. That’s all for today. See you next time at the end of this issue! ! !

This is the end of this article about teaching you how to use vue-cli3 to create a project in five minutes (for beginners). For more relevant vue-cli3 project creation content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Talk about the pitfalls I encountered with pre-rendering in vue-cli3
  • How to package Vue Cli3 and automatically ignore console.log statements
  • Solution to the problem that the console.log print result is [object Object]

<<:  Solution to Linux QT Kit missing and Version empty problem

>>:  MySQL 4 common master-slave replication architectures

Recommend

js date and time formatting method example

js date time format Convert the date and time to ...

Detailed explanation of Linux netfilter/iptables knowledge points

Netfilter Netfilter is a packet processing module...

Two ways to configure Vue global methods

Table of contents 1. Introduction 2. The first me...

RHCE installs Apache and accesses IP with a browser

1. at is configured to write "This is a at t...

MySQL master-slave data is inconsistent, prompt: Slave_SQL_Running: No solution

This article uses an example to describe the solu...

How to modify the master-slave replication options in MySQL online

Preface: The most commonly used architecture of M...

Example code of javascript select all/unselect all operation in html

Copy code The code is as follows: <html> &l...

Should I use Bootstrap or jQuery Mobile for mobile web wap

Solving the problem Bootstrap is a CSS framework ...

Solution to overflow of html table

If the table is wide, it may overflow. For exampl...

How to view the IP address of the Docker container

I always thought that Docker had no IP address. I...

Solve the problem of Syn Flooding in MySQL database

Syn attack is the most common and most easily exp...

How to Set Shortcut Icons in Linux

Preface Creating shortcuts in Linux can open appl...