目录

What should I do if an error occurs when EventChannel is used for communication during page startup using the has.navigateTo API?

Symptom

When the has.navigateTo API is used to start a new page, the two pages cannot communicate with each other through EventChannel. The error information is as follows:

Error message 1: [console]: disposePageLifetime -> trigger page lifetime error, lifetime: onLoad, message: this.eventChannel.on is not a function

Error message 2: [console]: JSVM error stack: TypeError: this.eventChannel.emit is not a function

Possible causes

When the minimum runtime version is set to 2.0.0 or later, the EventChannel instance of the page to be started has not been initialized in the onLoad phase. In this case, if you call methods such as on and emit, the error message "is not a function" will be displayed.

Solution

Move the initialization and use of the EventChannel instance from the onLoad callback to the onReady callback to ensure that the EventChannel instance is ready before its methods are called.

Rectification

This issue has been resolved in ASCF runtime 2.0.4.