[英]Remove v-on:click event programmatically from an element (VueJs)
How do I remove the v-on:click event from a div?如何从 div 中删除 v-on:click 事件?
<div v-on:click="RegistroT(1)" class="btn btn-secondary btn-block"
:disabled="HoraIngreso !== '00:00'">
<i class="fa fa-clock-o"></i>
<span id="TxtHoraIngreso" v-text="HoraIngreso"></span>
</div>
I tried this in a function called from the VueJS method created when the data is retrieved (from a JsonResult):我在从检索数据时创建的 VueJS 方法调用的函数中尝试了此操作(来自 JsonResult):
$('#TxtHoraIngreso').parent().addClass(this.HoraIngreso !== '00:00' ? 'disabled' : '');
But it does not work.但它不起作用。
Basically, when a user registers his time of entry, the next time he enters the web the button must be deactivated.基本上,当用户注册他的进入时间时,他下次进入网络时必须停用该按钮。
How do I remove the v-on:click event from a div?如何从 div 中删除 v-on:click 事件?
An easy way is to only call the event handler if the state is valid.一种简单的方法是仅在状态有效时才调用事件处理程序。
<button
type="button"
v-on:click="e => valid && onClickSubmit()"
>
Sign Up
</button>
onClickSubmit()
will only be executed if valid = true
onClickSubmit()
只有在valid = true
才会执行
<template>
<div class="button-wrapper">
<button class="btn btn-secondary btn-block" :class="{'disabled': isDisabled}" @click="someMethodName"></button>
</div>
</template>
<script>
export default
{
data()
{
return {
isDisabled: false
}
},
methods:
{
someMethodName()
{
setTimeout(() => {
this.isDisabled = true;
}, 3600);
}
}
}
</script>
But maybe I didn't understand your question ;>但也许我不明白你的问题;>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.