As a newcomer to vuetify
and vue
, I am currently trying to understand how to handle a click event on a <v-btn>
. (Using vue 2.6.10
and vuetify 2.0.0
)
(I was surprised to find that I couldn't locate a single functioning code snippet, despite searching extensively in both the official vuetify documentation and through Google.)
Code
Button
<v-btn color="primary" rounded @onclick.native="startQuiz">Start</v-btn>
Handler method from
methods
section of the parent component.startQuiz() { console.log('start'); alert('start'); }
After clicking the button, I am unable to see any console output in the browser, nor does the alert popup appear.
In the Vue plugin within the browser, under the Events
subsection, I can see the following events:
click $emit by <VBtn>
Questions
- How can I ensure that the
startQuiz
method is executed when the button is clicked?
Update - Summary
I studied the information available in the following link:
It appears that @onclick
is simply a shorthand for v-on:click
, and that onclick
is a JavaScript convention that is invalid in the context of vue.