v-on lắng nghe các sự kiện DOM (click, input, nhấn phím) và chạy một handler. Viết tắt của nó là @.
<script setup>
import { ref } from "vue";
const count = ref(0);
function increment() { count.value++; }
</script>
<template>
<button v-on:click="increment">Cú pháp đầy đủ</button>
<button @click="increment">Viết tắt (idiomatic)</button>
<button @click="count++">Biểu thức inline</button>
<button @click="increment($event, 'extra')">Truyền tham số + sự kiện</button>
</template>
Bạn có thể truyền tên method, một biểu thức inline, hoặc gọi method với tham số. Đối tượng sự kiện native có sẵn dưới dạng .
