Skip to content

Commit 6f2d58e

Browse files
eviIItlevy9527
authored andcommitted
fix: Vue.use doesn't work (#90)
close #89
1 parent 8478f4d commit 6f2d58e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

templates/src/index.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
// Import vue component
22
import Component from './{{componentName}}.vue'
33

4-
// install function executed by Vue.use()
5-
export function install(Vue) {
6-
if (install.installed) return
7-
install.installed = true
8-
Vue.component('{{componentNamePascal}}', Component)
9-
}
10-
11-
// Create module definition for Vue.use()
12-
const plugin = {
13-
install
4+
// `Vue.use` automatically prevents you from using
5+
// the same plugin more than once,
6+
// so calling it multiple times on the same plugin
7+
// will install the plugin only once
8+
Component.install = Vue => {
9+
Vue.component(Component.name, Component)
1410
}
1511

1612
// To auto-install when vue is found
@@ -21,7 +17,7 @@ if (typeof window !== 'undefined') {
2117
GlobalVue = global.Vue
2218
}
2319
if (GlobalVue) {
24-
GlobalVue.use(plugin)
20+
GlobalVue.use(Component)
2521
}
2622

2723
// To allow use as module (npm/webpack/etc.) export component

0 commit comments

Comments
 (0)