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

feat(mp): getApp() add methods #665

上级 718374e4
......@@ -15,10 +15,10 @@ const hooks = [
export default function parseBaseApp (vm, {
mocks,
initRefs
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store
}
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store
}
Vue.prototype.mpHost = __PLATFORM__
......@@ -64,8 +64,8 @@ export default function parseBaseApp (vm, {
app: this
}
this.$vm.$scope = this
// vm 上也挂载 globalData
this.$vm.$scope = this
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData
this.$vm._isMounted = true
......@@ -77,6 +77,13 @@ export default function parseBaseApp (vm, {
// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {}
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name]
})
}
initHooks(appOptions, hooks)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册