Skip to content

Commit 6fc76b3

Browse files
committed
fix: improve createLocalVue
1 parent fe51703 commit 6fc76b3

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/create-local-vue.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,27 @@ import cloneDeep from 'lodash/cloneDeep'
55

66
function createLocalVue (): Component {
77
const instance = Vue.extend()
8-
instance.version = Vue.version
9-
instance._installedPlugins = []
8+
9+
// clone global APIs
10+
Object.keys(Vue).forEach(key => {
11+
if (!instance.hasOwnProperty(key)) {
12+
instance[key] = cloneDeep(Vue[key])
13+
}
14+
})
15+
16+
// config is not enumerable
1017
instance.config = cloneDeep(Vue.config)
11-
instance.util = cloneDeep(Vue.util)
12-
instance._use = instance.use
18+
19+
// option merge strategies need to be exposed by reference
20+
// so that merge strats registered by plguins can work properly
21+
instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies
22+
23+
const use = instance.use
1324
instance.use = (plugin) => {
25+
// compat for vue-router < 2.7.1
1426
plugin.installed = false
1527
plugin.install.installed = false
16-
instance._use(plugin)
28+
use.call(instance, plugin)
1729
}
1830
return instance
1931
}

0 commit comments

Comments
 (0)