element.mount()
Use this method to mount the Element instance to the specified DOM container. After calling element.mount(), the SDK will create an iframe within the container and load the corresponding WebApp page.
Method signature
When calling this method, please use the following standard method signature format.
JavaScript
TypeScript
copy
element.mount(container)Parameters
Parameter | Data type | Required | Description |
container | HTMLElement | Yes | DOM container node (e.g., |
Return value
This method returns a Promise. You can use element.mount().catch() to capture exceptions during the mounting process.
Error codes
Use the element.on() method to listen for error codes related to the element.mount() method. For a detailed list of error codes, please refer to the Error codes.
Best practices
- Mounting timing: Mounting must be completed before calling
antom.confirmCardSetup()orantom.confirmPayment(). - Container requirements:
- Ensure the container element already exists in the DOM when calling
element.mount(). - It is recommended that the container width be no less than 375px, with no height restriction to allow the Element to expand automatically.
- Repeated mounting: The same Element instance can only be mounted once. Calling
element.mount()repeatedly will result in an exception. - Unmounting: To remove an Element, call the
element.unmount()method.