All Products
Search
Document Center

Mobile Platform as a Service:Event binding

Last Updated:May 08, 2023

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 Card components.

  • 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>

Examples

Click here detailBindEvent.zip for the complete sample code.