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

feat(h5): add options to page instance

上级 432625a2
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
......
......@@ -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')
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册