javascript - How to bind events only when conditions are met in vue
高洛峰
高洛峰 2017-05-16 13:36:29
0
1
649

 <button @click.prevent="getVerifyCode">获取验证码</button>

For example, a line of code like this, assuming I have a variable like isRightPhoneNumber, I hope that the above button will be enabled only when my isRightPhoneNumber is true What should I do if the event takes effect? One way I thought of is to add judgment in the getVerifyCode function, like this

if(!this.isRightPhoneNumber) return;

But I don’t really want to use this method, so I would like to ask if there is any other method, is there any method similar to v-if

{{messageLogin?'登录':'密码登录'}}
<form class='message-form' v-if='messageLogin'></form>
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
迷茫

:disabled="!isRightPhoneNumber"

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!