Skip to content

Commit

Permalink
chore: modify installation component method. update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
guastallaigor committed Jan 17, 2021
1 parent 350944f commit cb7c0bf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Or locally in any component

```js
import { VuePaycard } from 'vue-paycard'
// In v0.5+ you don't need the brackets above

export default {
components: {
Expand Down
42 changes: 34 additions & 8 deletions vue-paycard.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
import VuePaycard from './src/components/VuePaycard'
// Import vue component
import VuePaycard from './src/components/VuePaycard.vue'

const VuePaycardPlugin = {
install (Vue) {
Vue.component('VuePaycard', VuePaycard)
}
// install function executed by Vue.use()
const install = function (Vue) {
if (install.installed) return
install.installed = true
Vue.component('VuePaycard', VuePaycard)
}

// Export as a plugin
export default VuePaycardPlugin
// Create module definition for Vue.use()
const plugin = {
install
}

// To auto-install when vue is found
// eslint-disable-next-line no-redeclare
/* global window, global */
let GlobalVue = null

if (typeof window !== 'undefined') {
GlobalVue = window.Vue
} else if (typeof global !== 'undefined') {
GlobalVue = global.Vue
}

if (GlobalVue) {
GlobalVue.use(plugin)
}

// Inject install function into component - allows component
// to be registered via Vue.use() as well as Vue.component()
VuePaycard.install = install

// Export component by default
export default VuePaycard

// Export as individual components
// Export single (backwards compatibility)
export { VuePaycard }

0 comments on commit cb7c0bf

Please sign in to comment.