Component() constructor to add MorJS lifecycle hooks, mixin / behavior merging, pageLifetimes bridging for Alipay, $eventListener binding, and cross-platform adapter support.
Functions
createComponent
Registers a component with the MorJS runtime. Internally calls enhanceComponent and then the native Component() constructor.
Component configuration. Supports both Alipay and WeChat component shapes, plus MorJS extensions.
DSL source type. Determines how lifetimes (
onInit/didMount vs created/attached) are wired.aComponent
Registers an Alipay-style component. Equivalent to createComponent(options, SOURCE_TYPE.ALIPAY).
wComponent
Registers a WeChat-style component. Equivalent to createComponent(options, SOURCE_TYPE.WECHAT).
enhanceComponent
Applies all MorJS enhancements to a component options object without registering it with the platform.
The component options to enhance.
Source DSL type.
Feature flags that control which enhancements are applied.
The enhanced component options object.
registerComponentAdapters
Registers one or more component-level cross-platform adapters.
Adapter(s) whose
initComponent method will be called for every component registered with createComponent.Types
MorComponentOptions
Initial component data.
Component methods.
this is typed as MorComponentInstance<D, P> & M.Component lifetime hooks object. WeChat-style (
created, attached, ready, moved, detached, error); Alipay-style (onInit, deriveDataFromProps, didMount, didUpdate, didUnmount, onError).Array of mixin objects. Lifetime methods are merged; other methods use the last declaration.
Map of global event names to handlers. Registered on mount and removed on unmount via the shared
$event emitter.MorComponentAdapter
Called once per component registration after all enhancements are applied, before
Component() runs.MorComponentEnhanceFeatures
When
false, the component’s lifecycle methods do not fire the corresponding MorHooks. Used internally by PageToComponent where component-level hooks would be redundant.Lifecycle mapping
Alipay DSL
| Lifetime | MorHook |
|---|---|
onInit | componentOnInit |
didMount | componentDidMount |
didUnmount | componentDidUnmount |
onError | componentOnError |
WeChat DSL
| Lifetime | MorHook |
|---|---|
created | componentOnCreated |
attached | componentOnAttached |
detached | componentOnDetached |
error | componentOnError |
componentOnConstruct hook (or componentOnInit as a fallback) fires at the start of enhanceComponent.
pageLifetimes bridging
On Alipay targets, pageLifetimes.show / hide / resize are bridged via the shared $event emitter using page-scoped event names ($mor:pageOnShow:<flag>, etc.).