Skip to content

Commit

Permalink
feat(mp): getApp() add methods #665
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Nov 19, 2019
1 parent 718374e commit a653b7b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit a653b7b

Please sign in to comment.