An Element object corresponds to a component or sub-component, collectively referred to as a component. The second development code that is bound to a component will have its Element object assigned to the element property of that class.
Through this object, you can operate on the corresponding component, such as getting and setting properties, modifying settings, data linkage, listening to events, and more.
The Element object is created and bound by the system, so users do not need to construct it themselves.
1 | class Button { |
Getting the Component Name
1 | readonly name: string |
Getting Component Settings
1 | /** |
Modifying Component Settings
1 | /** |
Triggering Data Linkage
1 | /** |
Cancelling Data Linkage
1 | /** |
Getting Component Data (Deprecated, Use readData Instead)
1 | /** |
Reading Data
1 | /** |
Asynchronous Data Reading
1 | /** |
Adding Event Listeners to Components
1 | /** |
Triggering on Data Change
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
Triggering on Setting Change
Note: To prevent performance degradation due to large-scale listening, only fields that have been read will trigger callbacks.
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
Triggered when a postMessage event is received.
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
Triggered when the corresponding component is clicked by the mouse.
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
Triggered when the mouse enters the corresponding component.
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
Triggered when the mouse leaves the corresponding component.
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
Custom event names can be defined and triggered either through interactions or by using the emit method.
To add a custom event, use the following code:
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
You can trigger a custom event using the same element object by calling the emit method:
1 | //Note: Second development code only supports JS. For convenience, the example code uses TS here. |
Custom events can also be triggered by setting interactions:
Remove the event listener from the component.
1 | /** |
Trigger an event on the component.
1 | /** |
Determine if element is associated with the component.
1 | /** |
Get the instance object exposed by the component. This object can be used to perform some advanced functions.
1 | /** |
The following components expose an instance object:
The ECharts chart component exposes the ECharts instance object; refer to the ECharts documentation.
Get the list of all extended instances for the current element.
1 | /** |
Get the first extended instance of the current element.
1 | /** |
Get the list of child elements of the current element.
1 | /** |
Get the parent elements of the current element.
1 | /** |
Dynamically clone the current element. Note that this method is asynchronous and currently only applicable to elements in 3D mode.
1 | /** |
Delete the current element. Note that only cloned elements can be deleted. Calling this method on non-cloned elements will have no effect.
1 | /** |