Listens for DOM events with instructions.
https://jsfiddle.net/miloer/cz4ybz3e/
Vue provides event modifiers to resolve event.preventDefault() orevent.stopPropagation()。
<!--block Click event bubbling--><a v-on:click.stop= "Dothis" ></a><!--commit event no longer overloads the page--><form v-on: Submit.prevent= "OnSubmit" ></form><!--modifiers can be concatenated--><a v-on:click.stop.prevent= "Dothat" ><!-- Only modifier--><form v-on:submit.prevent></form>
<!--added two additional modifiers when adding event listeners using capture mode---1.0.16:
<div v-on:click.capture= "Dothis" >...</div><!--only the event triggers a callback--><div v-on when the element itself (not the child element) is triggered: click.self= "Dothat" >...</div>
There are also key modifiers:
<!--only KeyCode is 13 o'clock call Vm.submit ()--><input v-on:keyup.13= "Submit" >
all the key aliases: <v-on:keyup.enter=<input @keyup.enter="Submit" >
- Enter
- tab
- Delete
- Esc
- Space
- Up
- Down
- Left
- Right
Vue# method and event handler