Method: 1. Install node.js; 2. Install the vue-cli scaffolding building tool; 3. Use the "vue init webpack project name" command to build the project; 4. Use the "cnpm install" command to project dependencies; 5. Use the "npm run dev" command to run the project.
The operating environment of this tutorial: windows7 system, vue2.9.6 version, Dell G3 computer.
Related recommendations: "vue.js Tutorial"
First, list what we need:
- node.js environment (npm package manager)
- vue-cli scaffolding construction tool
- cnpm npm Taobao mirror
Installation node.js
Download and install node from the node.js official website. The installation process is very simple, just "next step" all the way (foolish installation).
After the installation is completed, open the command line tool and enter node -v, as shown below. If the corresponding version number appears, the installation is successful.
The npm package manager is integrated in node. Therefore, directly entering npm -v will display the npm version information as shown below.
OK! The node environment has been installed, and the npm package manager is also available. Because some npm resources are blocked or are foreign resources, it often fails when using npm to install dependency packages. Therefore, I also need npm's domestic mirror---cnpm.
Install cnpm
Enter npm install -g cnpm --registry=http://registry.npm.taobao.org in the command line and wait. The installation is completed as shown below.
After completion, we can use cnpm instead of npm to install dependent packages.
Install vue-cli scaffolding building tool
Run the command cnpm install -g vue-cli in the command line, and then wait for the installation to complete. (Note that cnpm is used here instead of npm, otherwise the speed will be super slow and will cause it to get stuck)
Through the above three steps, the environment and tools we need to prepare are ready. Next, start using vue-cli to build the project.
Build the project with vue-cli
To create the project, first we need to select the directory, and then change the directory to the selected directory on the command line. Here, I choose the desktop to store the new project, then we need to cd the directory to the desktop first, as shown below.
In the desktop directory, run the command vue init webpack firstVue in the command line. Explain this command. This command means to initialize a project, where webpack is the build tool, that is, the entire project is based on webpack. Among them, firstVue is the name of the entire project folder. This folder will be automatically generated in the directory you specify (in my example, the folder will be generated on the desktop), as shown below.
When running the initialization command, the user will be asked to enter several basic options, such as project name, description, author and other information. If you do not want to fill in the fields, just press Enter to default.
Open the firstVue folder, the project file is as follows.
This is the directory structure of the entire project. Among them, we mainly make changes in the src directory. This project is still just a structural framework, and the dependent resources required for the entire project have not yet been installed, as shown below.
Install the dependencies required for the project
To install the dependency package, first cd to the project folder (firstVue folder), and then run the command cnpm install, Waiting for installation.
After the installation is completed, there will be an additional node_modules folder in the firstVue folder of our project directory, which contains the dependency package resources required by our project.
#After installing the dependency packages, you can run the entire project.
Run the project
In the project directory, run the command npm run dev, which will run our application using hot loading. Hot loading allows us to modify the code without manually refreshing the browser. See the effects of modifications in real time.
Here is a brief introduction to the npm run dev command. The "run" corresponds to the dev in the scripts field in the package.json file, which is node. A shortcut for the build/dev-server.js command.
After the project runs successfully, the browser will automatically open localhost:8080 (if the browser does not open automatically, you can enter it manually). After running successfully, you will see the interface shown below.
If you see this page, it means the project is running successfully.
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of How to start a vue.js project. For more information, please follow other related articles on the PHP Chinese website!

Vue.js uses virtual DOM instead of directly operating DOM, in order to improve performance and development efficiency. 1) Virtual DOM is calculated through diff algorithm to minimize DOM operations and improve performance. 2) Simplify development, developers do not need to deal with DOM complexity. 3) Component reuse and combination are more efficient. The working principle of virtual DOM is to generate a comparison between the new tree and the old tree, update only the difference part, and reduce the number of DOM operations.

WhentheVue.jsVirtualDOMdetectsachange,itupdatestheVirtualDOM,diffsit,andappliesminimalchangestotherealDOM.ThisprocessensureshighperformancebyavoidingunnecessaryDOMmanipulations.

Vue.js' VirtualDOM is both a mirror of the real DOM, and not exactly. 1. Create and update: Vue.js creates a VirtualDOM tree based on component definitions, and updates VirtualDOM first when the state changes. 2. Differences and patching: Comparison of old and new VirtualDOMs through diff operations, and apply only the minimum changes to the real DOM. 3. Efficiency: VirtualDOM allows batch updates, reduces direct DOM operations, and optimizes the rendering process. VirtualDOM is a strategic tool for Vue.js to optimize UI updates.

Vue.js and React each have their own advantages in scalability and maintainability. 1) Vue.js is easy to use and is suitable for small projects. The Composition API improves the maintainability of large projects. 2) React is suitable for large and complex projects, with Hooks and virtual DOM improving performance and maintainability, but the learning curve is steeper.

The future trends and forecasts of Vue.js and React are: 1) Vue.js will be widely used in enterprise-level applications and have made breakthroughs in server-side rendering and static site generation; 2) React will innovate in server components and data acquisition, and further optimize the concurrency model.

Netflix's front-end technology stack is mainly based on React and Redux. 1.React is used to build high-performance single-page applications, and improves code reusability and maintenance through component development. 2. Redux is used for state management to ensure that state changes are predictable and traceable. 3. The toolchain includes Webpack, Babel, Jest and Enzyme to ensure code quality and performance. 4. Performance optimization is achieved through code segmentation, lazy loading and server-side rendering to improve user experience.

Vue.js is a progressive framework suitable for building highly interactive user interfaces. Its core functions include responsive systems, component development and routing management. 1) The responsive system realizes data monitoring through Object.defineProperty or Proxy, and automatically updates the interface. 2) Component development allows the interface to be split into reusable modules. 3) VueRouter supports single-page applications to improve user experience.

The main disadvantages of Vue.js include: 1. The ecosystem is relatively new, and third-party libraries and tools are not as rich as other frameworks; 2. The learning curve becomes steep in complex functions; 3. Community support and resources are not as extensive as React and Angular; 4. Performance problems may be encountered in large applications; 5. Version upgrades and compatibility challenges are greater.


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

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
