mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Added "componentName" param for optional component name (#53)
This commit is contained in:
15
README.md
15
README.md
@@ -22,9 +22,20 @@ npm install vue-js-modal --save
|
|||||||
Include plugin in your `main.js` file.
|
Include plugin in your `main.js` file.
|
||||||
|
|
||||||
```javascript
|
```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:
|
Create modal:
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import Modal from './Modal.vue'
|
import Modal from './Modal.vue'
|
||||||
|
|
||||||
|
const defaultComponentName = 'modal'
|
||||||
|
|
||||||
const Plugin = {
|
const Plugin = {
|
||||||
install (Vue, options = {}) {
|
install (Vue, options = {}) {
|
||||||
if (this.installed) {
|
if (this.installed) {
|
||||||
@@ -23,7 +25,8 @@ const Plugin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.component('modal', Modal)
|
const componentName = options.componentName || defaultComponentName
|
||||||
|
Vue.component(componentName, Modal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user