明明可以打印错误信息,但是el-form-item不显示error
经过搜索得知el-form-item
的error
属性监听的是watch
方法,也就是两次重复的错误操作,提示的错误信息一致,就不会触发watch方法
解决方案,在错误信息增加了Math.random().toFixed(2),在显示的时候再剪掉
<el-form-item label="网络地址" prop="cidr" :error="errorMsg.cidr?errorMsg.cidr.substring(4):''">
if (!this.subnet.cidr) {
this.errorMsg.cidr = Math.random().toFixed(2) + "请输入网络地址"
} else {
if (!this.publicFun.isIpv6Mask(this.subnet.cidr)) {
this.errorMsg.cidr = Math.random().toFixed(2) + "请输入正确IPV6地址,示例:2001:DB8:0:0:0:0:0:0/64"
console.log(this.errorMsg.cidr)
} else {
this.errorMsg.cidr = null
}
}
最后
以上就是暴躁铅笔最近收集整理的关于踩坑el-form :error多次错误信息一致不显示问题的全部内容,更多相关踩坑el-form内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复