单击禁用按钮时,有没有方法触发此特定功能?然后在按钮启用时触发另一个功能?
我试着做这样的黑客攻击,但它不起作用
<template>
<b-form @submit.prevent="game">
<b-row
class="mt-4"
v-on:click="invalid ? hello : ''"
>
<b-button
class="auth-button"
pill
:disabled="invalid"
type="submit"
>
重置密碼
</b-button>
</b-row>
</b-form>
</template>
<script>
data: function() {
return {
invalid: true
};
},
methods: {
hello() {
alert('Hello World')
}
game() {
alert('Game Over')
}
}
</script>
There is no way to capture a click on disabled elements. Your best bet is to react to a specific class on the element.
HTML Markup:
<input type="button" class="disabled" value="click" />
JavaScript code:
$('input').click(function (event) {
if ($(this).hasClass('disabled')) {
alert('CLICKED, BUT DISABLED!!');
} else {
alert('Not disabled. =)');
}
});