Home > Web Front-end > Vue.js > body text

Why vue.js needs to be mirrored

藏色散人
Release: 2023-01-13 00:45:13
Original
2247 people have browsed it

vue.js needs to be mirrored because the NPM installation method will be slower when building large-scale applications with Vue.js, so you can use Taobao's cnpm mirror to install vue.

Why vue.js needs to be mirrored

The operating environment of this article: windows7 system, vue2.0 version, DELL G3 computer.

Why is vue.js installed using cnpm mirror?

When building large-scale applications with Vue.js, it is recommended to use the NPM installation method. NPM can be used well with module packagers such as Webpack or Browserify. But since npm is foreign, it is relatively slow to use; you can use Taobao's cnpm image to install vue.

First we need to download npm, install node.js, and then install npm. Then, use npm to install the cnpm of the Taobao image.

1. Open cmd and enter the command

npm install -g cnpm —registry=https://registry.npm.taobao.org
Copy after login

Installing Vue requires npm version greater than 3, so we first upgrade npm, enter the command

cnpm install cnpm -g
Copy after login

to install vue, enter the command

cnpm install vue
Copy after login

Install vue-cli and enter the command

cnpm install —global vue-cli
Copy after login

Why vue.js needs to be mirrored

At this time, the environment has been set up.

Recommendation: "vue tutorial"

2. Specify the path to store the project and run the command

vue init webpack "project name"

After success, enter the directory where the project is located and run the command

cd "the folder where the project is located"

Then execute the following commands in sequence

cnpm install
Copy after login

Why vue.js needs to be mirrored

cnpm run dev
Copy after login

Why vue.js needs to be mirrored

Some screenshots are omitted in the middle. . . .

Why vue.js needs to be mirrored

After success, we enter the browser and enter localhost:8080 to display the following page.

Why vue.js needs to be mirrored

Project directory:

Next let’s take a look at the successfully created project above and enter the project directory

Why vue.js needs to be mirrored

The directory we develop is in src, src contains the following directory

Why vue.js needs to be mirrored

assets: stores mutations

components: stores a component file

App.vue: Project entry file, we can also write the components here directly instead of using the components directory

main.js: Project core file

Let’s take a look at App. The content of vue




Hello.vue



Copy after login

The above is the detailed content of Why vue.js needs to be mirrored. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!