vue form dynamic validator All In one
vue 动态校验表单 All In one
solutions ✅
inventoryTypesChange (values = []) {
if(!values?.length) {
this.rules.inventoryTypes[0].required = true;
} else {
this.rules.inventoryTypes[0].required = false;
}
// 手动校验
this.$emit('validate-field-by-key', 'inventoryTypes');
},
inventoryTypesChange (values = []) {
console.log('values =', values);
if(!values?.length) {
// this.$message.error('至少选择一个媒体');
// this.rules.inventoryTypes.message = '至少选择一个媒体';
this.rules.inventoryTypes[0].required = true;
} else {
this.rules.inventoryTypes[0].required = false;
}
console.log('this.rules.inventoryTypes', this.rules.inventoryTypes);
// 手动校验
this.$nextTick(() => {
this.$emit('validate-field-by-key', 'inventoryTypes');
});
},
refs
https://github.com/xgqfrms/vue/issues/199
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 ️,侵权必究⚠️!