Skip to main content
Version: 3.x

EventChannel

Inter-page event communication channel

Methods

emit

Trigger an event

Reference

(eventName: string, ...args: any) => void
PropertyTypeDescription
eventNamestringevent name
argsanyevent arguments

API Support

APIWeChat Mini-ProgramH5React Native
EventChannel.emit✔️✔️

off

Cancels listening to an event. If the second parameter is passed, only the specified listener is cancelled, otherwise all listener functions are cancelled.

Reference

(eventName: string, fn: EventCallback) => void
PropertyTypeDescription
eventNamestringevent name
fnEventCallbackevent handler

API Support

APIWeChat Mini-ProgramH5React Native
EventChannel.off✔️

on

Register a listener event

Reference

(eventName: string, fn: EventCallback) => void
PropertyTypeDescription
eventNamestringevent name
fnEventCallbackevent handler

API Support

APIWeChat Mini-ProgramH5React Native
EventChannel.on✔️

once

Register a listener event that expires after being triggered once.

Reference

(eventName: string, fn: EventCallback) => void
PropertyTypeDescription
eventNamestringevent name
fnEventCallbackevent handler

API Support

APIWeChat Mini-ProgramH5React Native
EventChannel.once✔️

API Support

APIWeChat Mini-ProgramH5React Native
EventChannel.emit✔️
EventChannel.off✔️
EventChannel.on✔️
EventChannel.once✔️