In front-end learning, after learning HTML, CSS, and JS, we usually choose to learn some frameworks, such as Jquery, AngularJs, etc. This series of blog posts is aimed at students learning Vue.js.
1. How to use Vue.js simply
Just like Jquery we have learned before, we can also use direct references when using Vue.js in the program method, download it directly and introduce it with the <script> tag, Vue.js will be registered as a global variable. Here is an important tip: there are two versions on the official website of Vue.js, the development version and the production version. We use the development version during development, and it will give corresponding warnings when encountering common errors. </script>
Of course, like Jquery, Vue.js can also be referenced in the code using CDN. Just copy and paste the code directly on the bootcdn website, it is simple and convenient.
2.vue environment construction
We recommend using NPM installation when building large-scale applications with Vue.js. NPM can be packaged well with modules such as Webpack or Browserify used in conjunction with the device. Vue.js also provides supporting tools to develop single-file components.
The recommended development environment for Vue.js is Nodejs. npm: is the package manager under Nodejs. Since using npm in China will be very slow, it is recommended to use the Taobao NPM mirror (its URL is http://npm.taobao.org/). We use webpack to merge and package resources and vue-cli to generate user-generated Vue project templates.
Then, let’s focus on how to build a suitable environment.
(1) How to install Nodejs
Open the official website of Nodejs (https://nodejs.org/en/), we can see Download in the middle of the page For this word, just select the corresponding version to download. It is recommended to download the later version. You can also choose Other Downloads below to download other versions and Mac versions.
After the download is complete, just use the fool-proof installation. After the installation is completed, you can first simply test whether the installation is successful, and then configure the environment. Press the [win R] key on the keyboard, enter cmd, and then press Enter to open the cmd window. Enter node -v and npm -v to display the currently installed version number, which means the installation is successful. The new version of Node.js has its own npm. The function of npm is to manage the packages that Node.js depends on. It can also be understood as the things that need to be installed and uninstalled by Node.js.
(2) Install cnpm
Since some npm resources are blocked or are foreign resources, it often occurs when npm is used to install dependent packages. Failed, so either FQ or use the domestic mirror cnpm. Open https://npm.taobao.org/, we can learn that this is a complete npmjs.org mirror, which can be used instead of the official version (read-only). The synchronization frequency is currently once every 10 minutes to ensure that it is synchronized with the official service as much as possible .
Also enter npm install -g cnpm --registry=http://registry.npm.taobao.org on the command line and wait.
After the installation is completed, we enter cnpm -v to check. When the following picture is displayed, the installation is successful.
(3) Install vue-cli
vue-cli is A global scaffolding is used to help build the required template framework. Similarly, enter the command in cmd: npm install -g vue-cli. In this piece of code -g means for global use. Like cnpm, a long list of files will be displayed after the installation is completed. Enter vue -v to view the vue version. At this point, the environment has been basically set up successfully.
(4) Test, create the first Vue.js project
Enter in the command line: vue init webpack my-first-demo(project folder name ).
The settings here and later can be entered, or you can directly press Enter and N.
In this way, the first Vue.js project is created. Open the corresponding storage address and you will see this file. Mine is placed under user/Lunlun/.
By typing cd my-first-demo, you can enter the directory specific folder and enter on the command line: cnmp install or npm install to install dependency packages. Re-open the folder under the path. We can see that there is one more node_modules folder in the folder than the previous one. The scaffolding installation is now complete.
(5) Enter: npm run dev in the command line.
This command will run our application using hot loading. Hot loading allows us to see the modified effects in real time without manually refreshing the browser after modifying the code.
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 a shortcut to the node 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. At this point, the task is completed.
This article introduces the installation and configuration of vue.js. For more related content, please pay attention to the php Chinese website.
Related recommendations:
JS implements browser printing and print preview
Inheritance implementation of js
The above is the detailed content of vue.js installation and configuration. For more information, please follow other related articles on the PHP Chinese website!

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.


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

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
