Handling Events

View saved

v-on and the @ shorthand

Attach handlers in the template.

<button type="button" @click="save">Save</button>
<input @keyup.enter="submit" />

Access the event

Use $event or accept it as a parameter in the handler.

<input @input="onInput" />

function onInput(event) {
  query.value = event.target.value;
}

Modifiers

Common helpers: .prevent, .stop, .once.

<form @submit.prevent="createNote">...</form>

Inline vs named handlers

Tiny updates can be inline; prefer named functions when logic grows.

<button type="button" @click="count++">+</button>

Comments

One comment per signed-in account. Comments are saved with this page’s URL.