This topic describes the event types and binding methods for Ant Dynamic Cards.
General events
You can bind the following two event types in a card template:
Click (click)
Long press (longpress)
Template usage
In template mode, event binding is similar to the Vue format and only supports instructions. These instructions also support a shorthand format. The name of a bindable event, such as @click in the sample code below, is determined by the component registered for the card. For more information about the components that can be registered for a card, see Card components.
The parameters of the bound handler function, such as param in the sample code below, can be expressions.
You can define the corresponding methods for your business logic in JavaScript (JS) within the <script> segment. There are no restrictions on the method parameters.
<template>
...
<text @click="click(param)"></text>
...
</template>
<script>
export default {
data: {
},
beforeCreate() {
},
methods: {
click(p) {
console.info("onclick");
}
}
}
</script>Sample code
Click detailBindEvent.zip to download the complete sample code.