1、对于验证el-form的时候,如果有显示隐藏,同时有验证必填或者其他的时候。最好是给el-form加上key,同时把验证规则卸载el-form上(不然可能失效)
2、对于循环出来的el-form
1、也是要给el-form加上key,不然会出现验证不准确的问题
2、监听某个字段的改变,重新验证该字段
// computed:
proxyIDChange() {
return this.signData.proxyList.map(item => item.id)
}
// watch
proxyIDChange: {
handler: function(newVal, oldVal) {
this.ValidateMainIDFn(newVal, 'proxyList', 'id')
},
deep: true
}
// methods
ValidateMainIDFn(newVal, protocolType, prop) {
let list = []
newVal.forEach((item, index) => {
if(item) {
list = [...list, `${protocolType}.${index}.${prop}`]
}
})
if(list.length <= 0) {
return
}
// 会出现index不准确的情况,所以用this.$nextTick
this.$nextTick(() => {
this.$refs.signData.validateField(list)
})
},