module 11 - forms Flashcards
how do you stop a button from submitting a form?
You listen on the form to the submit even and prevent it while calling another method. @submit.prevent=”another method”
what does @input do?
@input is a shorthand for the call v-on:input=”inputHandler” which is triggered on every key stroke
Will there be a difference between retrieving the value on an input with type=number using v-model vs. ref
When you use v-model you will get a number back. when you use ref you will get a string back. if you entered 5 and you do +4 to the value. the one retrieved with v-model will become 9 while the one retrieved by ref will become 54
what does v-model.lazy do?
if we don’t set this modifier the data will be updated on every key stroke. if we do set it then the value will be updated on a lower frequency.
what does v-model.trim do?
it removes white spaces before and after the value in the input.
how to connect a list of checkbox’s with v-model
the value in data backing the checkbox list needs to be an array and not just a single field. Each checkbox should have the same name and a different value which is what is going to be stored in the array
how to connect a list of radio buttons with v-model
Each radio button should have the same name and a different value which is what is going to be stored in the array
How do you connect a single checkbox with v-model
in case of a single checkbox we connect the v-model to a single field and the values there will be true/false
What happens if I give a button a type of button
Giving a button in a form a type of button revokes its default behavior of submitting the form.
what prop does v-model set on a custom component?
The prop is “modelValue”
what event is v-model listening to on a custom component?
The event that the custom component needs to emit in order to work with v-model is “update:modelValue”