Home  >  Article  >  Web Front-end  >  What is the difference between direct import of vue and npm

What is the difference between direct import of vue and npm

青灯夜游
青灯夜游Original
2021-09-01 12:20:424514browse

The difference between direct introduction of vue and npm: 1. Using npm to install Vue can facilitate package management. You can use Vue commands directly, use webpack tools to create projects, and front-end building tools will make front-end development more efficient; 2 , direct introduction method, when the application requires more and more front-end libraries and front-end frameworks, it will be very inconvenient to introduce them one by one in the HTML file.

What is the difference between direct import of vue and npm

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

There are two ways to use vue: directly quoting vue.js in HTML and npm installation.

1. Directly import vue.js in HTML

You can directly use script to import the vue.js file. The vue.js file can be downloaded directly from the official website, or you can use CDN

Official website download address: https://vuejs.org/js/vue.min.js

CDN address:

https://cdn.staticfile.org/vue/2.2.2/vue.min.js
https://unpkg.com/vue/dist/vue.js, 会保持和 npm 发布的最新的版本一致。
https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.8/vue.min.js

2. Use npm to install

Recommended reading "How to install vue.js with npm?

So what is the difference between the two methods of directly quoting vue.js in HTML and npm installation? Let me introduce to you

There is no difference between simply referencing from script and downloading from npm. You can also import it through script after downloading from npm.

The key point is that npm is a tool for package dependency management. As you can see, it is the recommended download method for development with other packages. When developing, you can use modular solutions such as require('vue') and import('vue'). You can use vue-cli to start a project to experience it.

Using npm to install Vue can facilitate package management. When the application requires more and more front-end libraries and front-end frameworks, it will be very inconvenient to introduce them one by one in the HTML file.

The npm method can use Vue commands directly, and will use the webpack tool to create projects. The front-end build tool will make front-end development more efficient.

Related recommendations: "vue.js Tutorial"

The above is the detailed content of What is the difference between direct import of vue and npm. 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