What happens in vue.use
vue.use is used to register global plug-ins. It receives a function or an object containing the install attribute as a parameter; if the parameter contains install, install will be executed. If not, the parameter will be executed directly as install; and the first The parameters are always vue objects, and registered plug-ins will not be re-registered.
The operating environment of this tutorial: windows7 system, vue2.0 version, Dell G3 computer.
Related recommendations: "vue.js Tutorial"
Definition
vue.use() injects a plug-in globally , for global real-time use, no need to quote separately
Code understanding:
import Router from 'vue-router' // 入口文件全局注入vue-router, 从而可以在全局使用this.$route Vue.use(Router)
If you do not use vue.use, you must introduce it separately if you need to use it in the component
// a.vue import Router from 'vue-router' // b.vue import Router from 'vue-router'
After understanding its basic use and function, let's take a look at what happens in vue.use
The source code is very small, so I directly excerpted it
Vue.use = function (plugin: Function | Object) { const installedPlugins = (this._installedPlugins || (this._installedPlugins = [])) if (installedPlugins.indexOf(plugin) > -1) { return this } // additional parameters const args = toArray(arguments, 1) args.unshift(this) if (typeof plugin.install === ‘function’) { plugin.install.apply(plugin, args) } else if (typeof plugin === ‘function’) { plugin.apply(null, args) } installedPlugins.push(plugin) return this }
Summary
vue.use() is used to register global plug-ins. It receives a function or an object containing the install attribute as a parameter. If the parameter contains install, install will be executed. If not, the parameter will be directly executed as install. The first parameter It is always a vue object, and registered plug-ins will not be re-registered.
The above is the detailed content of What happens in vue.use. For more information, please follow other related articles on the PHP Chinese website!

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Confusion and the cause of choosing from PHP to Go Recently, I accidentally learned about the salary of colleagues in other positions such as Android and Embedded C in the company, and found that they are more...

Mock interview AI tools are valuable tools for efficient candidate screening, saving recruiters time and effort. These tools include HireVue, Talview, Interviewed, iCIMS Video, and Eightfold AI. They provide automated, session-based assessments with benefits including efficiency, consistency, objectivity and scalability. When choosing a tool, recruiters should consider integrations, user-friendliness, accuracy, pricing, and support. Mock interviewing AI tools improve hiring speed, decision quality, and candidate experience.

Programmers' "tickling" needs: From leisure to practice, this programmer friend has been a little idle recently and wants to improve his skills and achieve success through some small projects...

Explore the implementation of panel drag and drop adjustment function similar to VSCode in the front-end. In front-end development, how to implement VSCode similar to VSCode...

The onBlur event that implements Avue-crud row editing in the Avue component library manually triggers the Avue-crud component. It provides convenient in-line editing functions, but sometimes we need to...

Vue Elementel-upload upload file online error reporting and troubleshooting using Vue and Element...

Programmers’ daily worries and skills monetization: from “I’m so idle” to “helpful” Recently, a programmer friend posted on a forum, expressing “I’m so idle…

Title: The relationship between technology stack convergence and selection: Does technology stack convergence refer to the selection of technology stack? I saw an article that has a convergence technology stack...
