Get API in Events
This guide explains how to obtain the API object for manipulating forms in event handlers and how to use the event injection feature to pass additional data.
Note
When you enable event injection through the inject configuration item, injected parameters are added as the first parameter in the callback event.
For more information, see the documentation Component Events
Data Structure
The parameter structure used by the event injection feature is as follows:
type InjectArg = {
api: APi,//api
rule: Rule[],//generation rules
self: Rule,//current generation rule
option: Object,//global configuration
inject: Any,//custom injected parameters
args: any[],//original callback parameters
}Inject api and Custom Data into Events
By configuring inject, you can inject the form API object and other custom data into event handler functions, making it easy to access and manipulate form data in events.
Global Enable
You can also globally enable event injection by setting the form configuration item injectEvent: true, so all events and native events automatically inject event parameters. This configuration is suitable for scenarios where you need to handle form APIs and other data uniformly across all events.


