我是靠谱客的博主 暴躁铅笔,这篇文章主要介绍踩坑el-form :error多次错误信息一致不显示问题,现在分享给大家,希望可以做个参考。

明明可以打印错误信息,但是el-form-item不显示error

经过搜索得知el-form-itemerror属性监听的是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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部