-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learning Vue.js 2
By :

Plugins in Vue.js are used for exactly the same purpose as they are used in any other scope: to add some nice functionality that, due to its nature, cannot be achieved with the core functionality of the system. Plugins written for Vue can provide various functionalities, starting from the definition of some global Vue methods or even the instance methods and moving toward providing some new directives, filters, or transitions.
In order to be able to use an existing plugin, you must first install it:
npm install some-plugin --save-dev
And then, tell Vue to use it in your application:
var Vue = require('vue')
var SomePlugin = require('some-plugin')
Vue.use(SomePlugin)
We can also create our own plugins. This is also easy. Your plugin must provide an install
method where you define any global or instance methods, or custom directives:
MyPlugin.install = function (Vue, options) { // 1. add global method or property Vue.myGlobalMethod...