el-message is clicked multiple times, multiple error messages pop up, the page is not beautiful, I just want to keep one, what should I do? This article perfectly solves this problem!!!
no nonsense,上代码:
data() {
return {
msgInstance: null, // 报错提示实例
}
},
methods:{
...
// 校验方法中, 报错前加入此行
if (!/^\d+$/.test(val)) {
if (this.msgInstance && !this.msgInstance.closed) return
this.msgInstance = this.$message.error('分配数量格式不正确,请重新输入')
}
...
}
Done! It's not easy to code, please like it and go~