-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: modify installation component method. update readme
- Loading branch information
1 parent
350944f
commit cb7c0bf
Showing
2 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |