How to disable the button in VueJS?

Hi Friends đź‘‹,

Welcome To SortoutCode! ❤️

Today, I am going to show you How do you disable the button in VueJS?

Table of Content

  • Setup the Vue (Optional)
  • Create FirstComponent.vue and import it into App.js
  • Disable the button

This article will guide you to how do I disable the button in vueJS.

Setup the Vue (Optional)

First, we have to install the Vue project, I had installed the vueJS in my system. If you haven’t installed or have any problem with installation you can follow this article, it will show you step by step process of installation.

How to Install the VueJS project?

Create FirstComponent.vue and import it into App.js

Create the new component in the src/components/ components folder. the component name is FirstComponent.vue and imported into the App.js file:

App.js

<template>
  <div id="app">
    <FirstComponent />
  </div>
</template>

<script>
import FirstComponent from "./components/FirstComponent.vue";
export default {
  name: "App",
  components: {
    FirstComponent,
  },
};
</script>

Disable the button

To disable the button we are going to add the disabled property to the button tag. Let’s see the code example:

FirstComponent.js

<template>
  <div id="app">
    <button disabled>Sortoutcode</button>
  </div>
</template>
<script>
  export default {
    name:'FirstComponent'
  }
</script>

For now, let’s check the output.

Disable button

All the best đź‘Ť.

Follow me on Twitter