Page() constructor to add MorJS lifecycle hooks, mixin composition, appLifetimes support, $eventListener binding, and cross-platform adapter invocation.
Functions
createPage
Registers a page with the MorJS runtime. Internally calls enhancePage and then the native Page() constructor.
The page configuration object. Supports both Alipay and WeChat page option shapes, plus MorJS extensions (
mixins, $eventListener, appLifetimes).Specifies the DSL source type (
SOURCE_TYPE.ALIPAY or SOURCE_TYPE.WECHAT). When omitted MorJS logs a warning because lifecycle handling differs between platforms.aPage
Registers an Alipay-style page. Equivalent to createPage(options, SOURCE_TYPE.ALIPAY).
wPage
Registers a WeChat-style page. Equivalent to createPage(options, SOURCE_TYPE.WECHAT).
enhancePage
Applies all MorJS enhancements to a page options object without registering it. Useful when you need the enhanced options for further processing (for example, PageToComponent).
The page options to enhance.
Source DSL type. Affects how
onResize is handled (Alipay puts it inside events, WeChat uses a top-level method).The mutated page options object with all lifecycle hooks wired and mixins merged.
registerPageAdapters
Registers one or more page-level cross-platform adapters.
Adapter(s) whose
initPage method will be called for every page created by createPage.Types
MorPageOptions
The complete page options type accepted by createPage, aPage, and wPage.
Array of mixin objects. Lifecycle methods are merged and called in order; non-lifecycle methods use the last-declared version; data and object fields are shallow-merged.
Map of global event names to handler functions. MorJS registers these on the shared
$event emitter when the page loads and removes them on unload.Handlers that fire when the host app shows or hides, while this page is active. Registered in
onLoad and unregistered in onUnload.MorPageAdapter
Called once per page registration, after all enhancements are applied but before the native
Page() constructor runs.Lifecycle hooks
The following page lifecycle methods are intercepted by MorJS:| Method | MorHook | Notes |
|---|---|---|
onLoad | pageOnLoad | Also registers $eventListener and appLifetimes |
onReady | pageOnReady | Emits $mor:pageOnReady:<flag> |
onShow | pageOnShow | Emits $mor:pageOnShow:<flag> |
onHide | pageOnHide | Emits $mor:pageOnHide:<flag> |
onUnload | pageOnUnload | Removes event listeners and appLifetimes |
onResize | — | Emits $mor:pageOnResize:<flag>; Alipay uses events.onResize |
pageOnConstruct hook (falling back to pageOnInit) fires at the start of enhancePage.
Alipay-specific lifecycle methods (via mixins)
onTitleClick, onOptionMenuClick, onPopMenuClick, onPullIntercept, onTabItemTap
WeChat-specific lifecycle methods (via mixins)
onShareTimeline, onResize, onAddToFavorites