提交 12e80116 编写于 作者: fxy060608's avatar fxy060608

refactor(qa): __VueOptions=>__VuePlugin

上级 b4aa9e49
/* eslint-disable no-undef */
if (typeof __VueOptions !== 'undefined') {
// 将 main.js 中的 store,use,mixin 同步到 page
const {
uses,
mixins,
store
} = __VueOptions
uses && uses.forEach(use => {
Vue.use(use)
})
mixins && mixins.forEach(mixin => {
Vue.mixin(mixin)
})
store && (Vue.prototype.$store = store)
if (typeof __VuePlugin !== 'undefined') {
Vue.use(__VuePlugin)
}
const injectRef = Object.getPrototypeOf(global) || global
// 目前仅支持 store, use, mixin, component
const vueOptions = Object.create(null)
let store
const mixins = []
const plugins = []
const components = []
function Vue (options) {
if (options && options.store) {
vueOptions.store = options.store
store = options.store
}
}
Vue.use = function (plugin) {
(vueOptions.uses || (vueOptions.uses = [])).push(plugin)
plugins.push(plugin)
}
Vue.mixin = function (mixin) {
(vueOptions.mixins || (vueOptions.mixins = [])).push(mixin)
mixins.push(mixin)
}
Vue.component = function (id, definition) {
components.push({
id,
definition
})
}
Vue.component = function () {}
const injectRef = Object.getPrototypeOf(global) || global
injectRef.__VuePlugin = {
install (Vue, options) {
mixins.forEach(mixin => {
Vue.mixin(mixin)
})
plugins.forEach(plugin => {
Vue.use(plugin)
})
injectRef.__VueOptions = vueOptions
components.forEach(({
id,
definition
}) => {
Vue.component(id, definition)
})
// 目前仅支持 store, use, mixin
store && (Vue.prototype.$store = store)
}
}
export default Vue
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册