From f981168904c4430e5da848c4e75105e464fa8300 Mon Sep 17 00:00:00 2001 From: euvl Date: Mon, 31 Jul 2017 15:06:07 +0100 Subject: [PATCH] Added "componentName" param for optional component name (#53) --- README.md | 15 +++++++++++++-- src/index.js | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0d81159..09f421a 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,20 @@ npm install vue-js-modal --save Include plugin in your `main.js` file. ```javascript -import vmodal from 'vue-js-modal' +import VModal from 'vue-js-modal' -Vue.use(vmodal) +Vue.use(VModal) + +/* +By default plugin will use "modal" name for the component. +If you need to change it, you can do so by supplying "componentName" option. + +Example: + +Vue.use(VModal, { componentName: "foo-modal" }) +... + +*/ ``` Create modal: diff --git a/src/index.js b/src/index.js index bb44ed4..c58c659 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,7 @@ import Modal from './Modal.vue' +const defaultComponentName = 'modal' + const Plugin = { install (Vue, options = {}) { if (this.installed) { @@ -23,7 +25,8 @@ const Plugin = { } } - Vue.component('modal', Modal) + const componentName = options.componentName || defaultComponentName + Vue.component(componentName, Modal) } }