Created
October 29, 2018 14:01
-
-
Save christopheragnus/4a3f2633db0436e7750fbd6ecf43e73b to your computer and use it in GitHub Desktop.
Vuejs Actions / Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calls addToCart method on component: | |
<button v-on:click="addToCart"> | |
// Shorthand | |
<button @click="addToCart"> | |
// Arguments can be passed: | |
<button @click="addToCart(product)"> | |
// To prevent default behaviour eg. page reload | |
<form @submit.prevent="addProduct"> | |
// Only trigger once: | |
<img @mouseover.once="showImage"> | |
//Stop all event prpagation | |
.stop | |
// Only trigger if event.target is element itself | |
.self | |
// Keyboard entry example | |
<input @keyup.enter="submit"> | |
// Call onCopy when control-c is pressed: | |
<input @keyup.ctrl.c="onCopy"> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment