diff --git a/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js b/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js index 2a05720f1a1dd017d40b82c5c1b40d361adb57a4..f0fea7f2879fa9b3b5964b77264f96c250572c7f 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +++ b/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js @@ -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)