Skip to content

Commit 77ba15b

Browse files
authoredJun 24, 2020
feat: auto install when using CDN (#403)
1 parent 1c64108 commit 77ba15b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed
 

‎src/index.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Vue, { VueConstructor } from 'vue'
22
import { Data, SetupFunction, SetupContext } from './component'
3-
import { currentVue } from './runtimeContext'
43
import { install } from './install'
54
import { mixin } from './setup'
65

@@ -10,17 +9,12 @@ declare module 'vue/types/options' {
109
}
1110
}
1211

13-
const _install = (Vue: VueConstructor) => install(Vue, mixin)
14-
const plugin = {
15-
install: _install,
16-
}
17-
// Auto install if it is not done yet and `window` has `Vue`.
18-
// To allow users to avoid auto-installation in some cases,
19-
if (currentVue && typeof window !== 'undefined' && window.Vue) {
20-
_install(window.Vue)
12+
const VueCompositionAPI = {
13+
install: (Vue: VueConstructor) => install(Vue, mixin),
2114
}
2215

23-
export default plugin
16+
export default VueCompositionAPI
17+
2418
export { nextTick } from './nextTick'
2519
export { default as createElement } from './createElement'
2620
export { SetupContext }
@@ -40,3 +34,8 @@ export * from './apis/lifecycle'
4034
export * from './apis/watch'
4135
export * from './apis/computed'
4236
export * from './apis/inject'
37+
38+
// auto install when using CDN
39+
if (typeof window !== 'undefined' && window.Vue) {
40+
window.Vue.use(VueCompositionAPI)
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.