artyak's avatar

How to make disabled button after click in Vuejs

I have a button on my website that gives bonuses to the user. Button have several conditions in 1 button:

<button class="btn btn--small btn--purple" :disabled="isDisabled" @click="takeBonus">Take</button>

 <script>
 ......
  computed: {
    isDisabled() {
      return this.heal_used === 1 || this.diff < 10;
      this.$forceUpdate();
    },
  },
.......
</script

But when user click Take button, and if all success, button is still active his.$forceUpdate(); not working. And i need make when user click Take button, and if all success, make this button disabled.

How i can make it?

0 likes
3 replies
martinbean's avatar

@artyak It’s not really possible to say without seeing the rest of your component, or what this.$forceUpdate() is doing. You don’t really want to be doing actions in computed properties; computed properties should just return a value only.

Please or to participate in this conversation.