Added "componentName" param for optional component name (#53)

This commit is contained in:
euvl
2017-07-31 15:06:07 +01:00
parent cd42709c03
commit f981168904
2 changed files with 17 additions and 3 deletions

View File

@@ -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" })
...
<foo-modal name="bar"></foo-modal>
*/
```
Create modal:

View File

@@ -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)
}
}