Given this tutorialhttps:// vuejs.org/guide/essentials/event-handling.html#accessing-event-argument-in-inline-handlers
In the code shown below, I call .preventDefault
to expect the normal behavior of canceling the click
event. Or in other words, I expect that once .preventDefault
is called, the button will no longer be clickable because from my understanding, .preventDefault
will disable the button's normal functionality .
But what happens is that the button is still clickable, as if .preventDefault
has no effect.
Please tell me how to properly use .preventDefault
to disable button clicks.
Code:
preventDefault is useful in the following situations:
To disable the button in your case you can use:
preventDefault()
will not disable the button, but will prevent its default action, which will be mainly noticed in theSubmit
action.To disable a button on click, you need to do something like this: