Recall & Review
beginner
What does the
.prevent event modifier do in Vue?The
.prevent modifier calls event.preventDefault() automatically. It stops the default browser action, like preventing a form from submitting or a link from navigating.Click to reveal answer
beginner
Explain the purpose of the
.stop event modifier in Vue.The
.stop modifier calls event.stopPropagation(). It stops the event from bubbling up to parent elements, so only the current element handles it.Click to reveal answer
beginner
How does the
.once event modifier affect event handling in Vue?The
.once modifier makes the event listener run only once. After the first event triggers, Vue automatically removes the listener.Click to reveal answer
intermediate
Show a Vue template example using
.prevent and explain what happens when the event triggers.<form @submit.prevent="submitForm"> <button type="submit">Send</button> </form>
When the button is clicked, the form's default submit action is stopped. Instead, the submitForm method runs without reloading the page.
Click to reveal answer
intermediate
Why would you use
.stop and .prevent together in Vue event handling?Using
.stop.prevent stops the event from bubbling up and also prevents the default browser action. This is useful when you want full control over the event on the current element only.Click to reveal answer
What does the Vue event modifier
.once do?✗ Incorrect
.once makes the event listener run only once, then Vue removes it automatically.Which event modifier prevents the default browser action in Vue?
✗ Incorrect
.prevent calls event.preventDefault() to stop default actions like form submission.If you want to stop an event from bubbling up to parent elements, which modifier do you use?
✗ Incorrect
.stop calls event.stopPropagation() to stop event bubbling.What happens if you use
@click.prevent.stop on a button?✗ Incorrect
Both
.prevent and .stop modifiers work together to prevent default action and stop bubbling.Which modifier would you use to ensure a form does not reload the page on submit?
✗ Incorrect
Using
.prevent on form submit stops the page reload by preventing the default submit action.Describe how the Vue event modifiers
.prevent, .stop, and .once work and when you might use each.Think about controlling browser behavior and event flow.
You got /4 concepts.
Explain why combining
.prevent and .stop modifiers might be useful in a Vue component.Consider a button inside a form or nested elements.
You got /4 concepts.