mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Refactored, added es5 build
This commit is contained in:
28
src/index.js
Normal file
28
src/index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import Vue from 'vue'
|
||||
import Modal from './Modal.vue'
|
||||
|
||||
const ModalPlugin = {
|
||||
install(Vue, options = {}) {
|
||||
if (!this.hasOwnProperty("event")) {
|
||||
this.event = new Vue()
|
||||
}
|
||||
|
||||
const $modal = {
|
||||
show(name, params) {
|
||||
ModalPlugin.event.$emit('toggle', name, true, params)
|
||||
},
|
||||
hide(name, params) {
|
||||
ModalPlugin.event.$emit('toggle', name, false, params)
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(Vue.prototype, '$modal', {
|
||||
get: () => $modal
|
||||
})
|
||||
|
||||
Vue.component('modal', Modal)
|
||||
return null
|
||||
},
|
||||
}
|
||||
|
||||
export default ModalPlugin
|
||||
Reference in New Issue
Block a user