Creating a plugin with options defined

Due to the way we have set up our project, we will leave SimplePlugin as is and, in this section of our exploration of plugins in Vue, we'll add another folder inside our plugins folder in our project. We'll call this folder OptionsPlugin and inside of it, we'll again create an index.js file.

Next, let's update the main.js file, so that now it looks like this:

import Vue from 'vue'import App from './App.vue'//import SimplePlugin from './plugins/SimplePlugin'import OptionsPlugin from './plugins/OptionsPlugin'//Vue.use(SimplestPlugin)Vue.use(OptionsPlugin)Vue.config.productionTip = falsenew Vue({  render: h => h(App)}).$mount('#app')

Now, back in OptionsPlugin/index.js, we will add the following code:

Get Vue.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.