# @on

The @on directive is typically used to listen to events triggered on a component, including custom events within the component and native DOM events, and can accept an expression to be executed after the event is triggered.

# Usage

  1. Syntax for listening to custom events:

    <component @on.custom-event-name="expression"></component>
    
  2. Syntax for listening to native DOM events:

    <component @on.native.click="expression"></component>
    

# Example

The following example demonstrates the usage of the custom events and native DOM events through two buttons. Please click the run button to start the example: