Vue3 basic + advanced (1. Vue3 project creation and familiarity with the project structure compared to vue2)

Table of contents

Chapter 1, Understanding create-vue

1.1 Introduction

1.2 Create a project using create-vue

1.2.1 Creation steps and precautions

1.2.2 Precautions

1.2.3 Familiar with the project, distinguish it from vue2


Chapter 1, Understanding create-vue

1.1 Introduction

create-vue is a new scaffolding tool on Vue's official website . The bottom layer is switched to vite (next-generation front-end tool chain) to provide rapid response for development.

1.2 Create a project using create-vue

1.2.1 Creation steps and precautions

  • Node version: above 16.0.0, check the version

 (Provide you with the specific operation of node version management)

Nvm installs and configures environment variables Use nvm to install and switch nodejs_nvm to configure environment variables_❆VE❆'s Blog-CSDN Blog

  • Create with command: npm init vue@latest
npm init vue@latest

(Note here, the prompt needs to download the corresponding version, just select y to download) 

  • Understand and configure options (the first time you create a vue3 project, follow the configuration below)

  • When the creation is complete, a notice will pop up: (if not, just ignore it)

Here we can update the version, use the command: npm install -g [email protected]

npm install -g [email protected]

 Check version:

  •  After confirming that there is no problem with the above:

 Enter the project, initialize the project, run the project

  • After running the project, click on the path

When the following page appears, it means the creation is successful:

1.2.2 Precautions

  • Prerequisite: install at least a node version higher than 16.0
  • Create a Vue application: npm init vue@latest

1.2.3 Familiar with the project, distinguish it from vue2

  • package.json: project package file—commands and dependencies of local projects: the core dependency becomes Vue3.x and the bottom layer of vite as the driver

  • vite.config.js: project configuration file - vite-based configuration

  •  main.js: entry file - createApp function to create an application instance

  • App.vue: root component - SFC single file component sequence script - template - style changes and the template template no longer requires a unique root element; script supports setup combined api

Guess you like

Origin blog.csdn.net/qq_45796592/article/details/130659899