Categories
Vue Answers

How to disable a button in Vue.js?

Spread the love

Sometimes, we want to disable a button in Vue.js.

In this article, we’ll look at how to disable a button in Vue.js.

How to disable a button in Vue.js?

To disable a button in Vue.js, we set the disabled prop of the button.

For instance, we write

<template>
  <div>
    <button :disabled="isDisabled">Send Form</button>
  </div>
</template>

to set the disabled prop to the isDisabled reactive property.

Therefore, the disabled attribute will be added to the button only if isDisabled is true.

Conclusion

To disable a button in Vue.js, we set the disabled prop of the button.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *