Skip to content

Commit

Permalink
fix: 为兼容mpvue,页面对象增加$mp属性 close #227
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed Mar 6, 2019
1 parent d11a8f2 commit 193a2c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/core/service/plugins/page/create-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ export default function createPage (pageVm) {
route: $route.meta.pagePath,
meta: Object.assign({}, $route.meta)
}
}
// 兼容 mpvue
pageVm.$vm = pageVm
pageVm.$root = pageVm
// 补充 mp 相关属性
pageVm.$mp = {
mpType: 'page',
page: pageVm,
query: {},
// 暂不支持
status: ''
}
}
3 changes: 2 additions & 1 deletion src/core/service/plugins/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function callPageHook (vm, hook, ...params) {
// hack 一下,H5 平台通知 View 层onShow,方便 View 层来切换 scroll 事件监听
if (__PLATFORM__ === 'h5') {
if (hook === 'onLoad') {
vm.$mp.query = params[0]
UniServiceJSBridge.publishHandler('onPageLoad', vm, vm.$page.id)
}
if (hook === 'onShow') {
Expand All @@ -27,4 +28,4 @@ export function callPageHook (vm, hook, ...params) {
console.debug(`${vm.$page.route}[${vm.$page.id}]:${hook} have been invoked`)
}
return callHook(vm, hook, params)
}
}

0 comments on commit 193a2c3

Please sign in to comment.