v-on 监听 DOM 事件(点击、输入、按键)并运行处理程序。其简写是 @。
vue
<script setup>
import { ref } from "vue";
const count = ref(0);
function increment() { count.value++; }
</script>
<template>
<button v-on:click="increment">Full syntax</button>
<button @click="increment">Shorthand (idiomatic)</button>
<button @click="count++">Inline expression</button>
<button @click="increment($event, 'extra')">Pass args + the event</button>
</template>
你可以传递方法名、内联表达式或使用参数调用方法。原生事件对象可作为 $event 使用。
