Last active
April 16, 2020 14:10
-
-
Save NickyMeuleman/38f58a371f1685d9c01cfcb1c49b0cf9 to your computer and use it in GitHub Desktop.
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
<template> | |
<!-- pass in the "like" variable that corresponds to the input-value by using v-model --> | |
<form v-on:submit.prevent="onSubmit(like)"> | |
<label | |
>What do you like: | |
<input v-model="like" /> | |
</label> | |
<input type="submit" /> | |
</form> | |
</template> | |
<script> | |
export default { | |
methods: { | |
onSubmit(thing = "turtles") { | |
console.log(`I like ${thing}.`); | |
// equivalent code that doesn't use an argument | |
// console.log(`I like ${this.like ?? "turtles"}.`); | |
}, | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment