ElementUI rules format
note: the rules should in data() {}
data () {
return {
rules: {
productKey: { required: true, message: '请选择产品', trigger: 'change' },
// errorCode: { required: true, message: '请填写故障代码', trigger: ['change', 'blur'] },
errorNum: { required: true, message: '请填写故障位', trigger: ['change', 'blur'] },
errorDesc: { required: true, message: '请填写故障详情', trigger: ['change', 'blur'] }
},
}
}
Form validate trigger by event
methods: {
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
alert('submit!');
} else {
console.log('error submit!!');
return false;
}
});
}
}
Top comments (0)