search
HomeWeb Front-endJS Tutorialvue.js installation and configuration

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

JS callback function example

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Replace String Characters in JavaScriptReplace String Characters in JavaScriptMar 11, 2025 am 12:07 AM

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

Custom Google Search API Setup TutorialCustom Google Search API Setup TutorialMar 04, 2025 am 01:06 AM

This tutorial shows you how to integrate a custom Google Search API into your blog or website, offering a more refined search experience than standard WordPress theme search functions. It's surprisingly easy! You'll be able to restrict searches to y

Build Your Own AJAX Web ApplicationsBuild Your Own AJAX Web ApplicationsMar 09, 2025 am 12:11 AM

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

Example Colors JSON FileExample Colors JSON FileMar 03, 2025 am 12:35 AM

This article series was rewritten in mid 2017 with up-to-date information and fresh examples. In this JSON example, we will look at how we can store simple values in a file using JSON format. Using the key-value pair notation, we can store any kind

10 jQuery Syntax Highlighters10 jQuery Syntax HighlightersMar 02, 2025 am 12:32 AM

Enhance Your Code Presentation: 10 Syntax Highlighters for Developers Sharing code snippets on your website or blog is a common practice for developers. Choosing the right syntax highlighter can significantly improve readability and visual appeal. T

8 Stunning jQuery Page Layout Plugins8 Stunning jQuery Page Layout PluginsMar 06, 2025 am 12:48 AM

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

10  JavaScript & jQuery MVC Tutorials10 JavaScript & jQuery MVC TutorialsMar 02, 2025 am 01:16 AM

This article presents a curated selection of over 10 tutorials on JavaScript and jQuery Model-View-Controller (MVC) frameworks, perfect for boosting your web development skills in the new year. These tutorials cover a range of topics, from foundatio

What is 'this' in JavaScript?What is 'this' in JavaScript?Mar 04, 2025 am 01:15 AM

Core points This in JavaScript usually refers to an object that "owns" the method, but it depends on how the function is called. When there is no current object, this refers to the global object. In a web browser, it is represented by window. When calling a function, this maintains the global object; but when calling an object constructor or any of its methods, this refers to an instance of the object. You can change the context of this using methods such as call(), apply(), and bind(). These methods call the function using the given this value and parameters. JavaScript is an excellent programming language. A few years ago, this sentence was

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

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),