All Products
Search
Document Center

Mobile Platform as a Service:Event binding

Last Updated:Nov 25, 2025

This topic describes the types of events that can be bound to Ant Cube Card and the binding methods.

Common events

In a card, there are two types of events that can be bound to the template:

  • Click

  • Longpress

Template usage

In template mode, event binding only supports the command format. The command form supports the shorthand format. The name of the event that can be bound to the card. The name of the event that can be bound to the card (@ click in the following sample code) is determined by the card-registered component. For more information about the card-registered components, see div.

  • The bound handler parameter (param in the following sample code) supports expressions.

  • You can define the corresponding business JS method in the <script> section, with no restrictions on the parameters of the method.

<template>
...
        <text @click="click(param)"></text>
...
</template>

<script>
    export default {
        data: {
        },
        beforeCreate() {
        },
        methods: {
            click(p) {
                console.info("onclick");                
            }
        }
    }
</script>

Example code

Click here detailBindEvent.zip for the complete sample code.