vue.js - Vuejs中的Vuelidate名称?
问题描述
fullname: '',
max: 30,
fullname: { required, minLength: minLength(30), maxLength: maxLength(29) },
computed: {
isDisabled: function(){
return !this.terms || (this.fullname.length < this.max) || (this.mobile.length < this.maxmobile)
|| (this.gstin.length < this.maxgstin) || (this.email.length < this.maxemail);
},
<input
type="text"
id='fullname' v-model='fullname'
v-model.trim="$v.fullname.$model"
:class="{ 'is-invalid': validationStatus($v.fullname) }"
class="input-section"
:maxlength="max"
v-on:keypress="isLetter($event)"
placeholder="Enter your name"
/>
<button class="register-button":disabled='isDisabled'
v-on:click=" isFirstScreen">PROCEED</button>
如果我保持 maxfullname=10 的条件,则在输入 10 个字符后,仅启用按钮。但我需要全名的 maxlength 应该是 30 个字符,即使用户输入少于 30 个字符(10、5、6....等),也必须启用按钮。
解决方案
fullname: { required, maxLength: maxLength(29) },
computed: {
isDisabled: function() {
return !this.terms || (this.fullname < this.max) || (this.mobile.length < this.maxmobile)
|| (this.gstin.length < this.maxgstin) || (this.email.length < this.maxemail);
},
推荐阅读
- linux - 单击并粘贴到剪贴板时如何从另一个应用程序获取小部件?
- flutter - 如何将选定的值存储在字符串中,以便在重新启动应用程序后显示最后选定的值?
- javascript - 我在理解事件系统方面有问题
- javascript - 使用可选链接运算符进行对象属性访问
- mysql - SQL UPDATE SET 列等于相关表中的 MIN 和 MAX 值
- linux - Bash:-c:第 0 行:意外的 EOF
- excel - 不先打开就无法读取 excel (XLS) 文件
- c++ - 非默认运算符 <=> 在 C++20 中不会生成 == 和 !=
- javascript - 在javascript中的页面加载时元素不会隐藏
- node.js - 如何使用异步 json 数据?