I'd bind a button to input using v-bind with a function :
The code inside my template :
<template>
<input
type="email"
v-model="email"
v-bind:placeholder="$t('fields.email_place_holder')"
/>
<input
v-bind:disabled="{ isDisable }"
type="submit"
v-bind:value="$t('buttons.notify_me')"
class="notify-me-button"
/>
</template>
The code inside my script :
methods: {
isDisable() {
return email.lenght > 0;
}
}
But the button does not change its status , I tried to change the css style with the same way and the result is the same.The problem is that button responds once time on the first value returned by isDisable().
isDisableto a computed property instead or replaceisDisablewith the condition you're checking for. i.e.<input :disabled="email.length > 0" type="submit" v-bind:value="$t('buttons.notify_me')" class="notify-me-button" />console.log()I find that method executes once time not each time I type in the field.computed: { emailLength: function () { return this.email.lenght > 0;}}The reason why the method executes only once is that it's not reactive. This is reactive and would change as the value ofemailchanges.