From b3192d48a2f57ae13bb1433b125ac7fef5053158 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 23 Apr 2020 17:06:13 +0800 Subject: [PATCH] feat(h5): add options to page instance --- src/core/service/plugins/page/create-page.js | 8 ++++++-- src/core/service/plugins/page/index.js | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/service/plugins/page/create-page.js b/src/core/service/plugins/page/create-page.js index b5f2aa9fc..a5c37c665 100644 --- a/src/core/service/plugins/page/create-page.js +++ b/src/core/service/plugins/page/create-page.js @@ -1,16 +1,20 @@ import { hasOwn -} from 'uni-shared' +} from 'uni-shared' -export default function createPage (pageVm) { +export default function createPage (pageVm, options) { const $route = pageVm.$route pageVm.route = $route.meta.pagePath + if (!pageVm.options) { // 可能开发者会声明 options 属性 + pageVm.options = options + } const id = hasOwn($route.params, '__id__') ? $route.params.__id__ : $route.meta.id pageVm.__page__ = { id, path: $route.path, route: $route.meta.pagePath, + options: options, meta: Object.assign({}, $route.meta) } // 兼容 mpvue diff --git a/src/core/service/plugins/page/index.js b/src/core/service/plugins/page/index.js index 8a4beb2ba..19ea00761 100644 --- a/src/core/service/plugins/page/index.js +++ b/src/core/service/plugins/page/index.js @@ -20,8 +20,9 @@ function getDecodedQuery (query = {}) { export function createPageMixin () { return { created: function pageCreated () { - createPage(this) - callPageHook(this, 'onLoad', getDecodedQuery(this.$route.query)) + const options = getDecodedQuery(this.$route.query) + createPage(this, options) + callPageHook(this, 'onLoad', options) callPageHook(this, 'onShow') } } -- GitLab