一、ref="addApply" :model="addApply" :rules="ruleValidate"   不要忘记prop

vue iview modal弹出框 form表单验证-LMLPHP

二、规则

vue iview modal弹出框 form表单验证-LMLPHP

三、

vue iview modal弹出框 form表单验证-LMLPHP
vue iview modal弹出框 form表单验证-LMLPHP
_createApply(name){
this.$refs[name].validate((valid) => {
if (valid) {
let addApply = Object.assign({},this.addApply)
addApply.serviceEndDate = formatDate(new Date(addApply.serviceEndDate),'yyyy-MM-dd')
createApply(addApply).then(res=>{
if(res.data.errcode ===0){
this.dialogAdd = false
this.$Message.info('创建成功!')
this._getApplyList()
this.$refs[name].resetFields();
} else if(res.data.errcode === 40199){
this.$Message.error('创建失败,该书库应用已存在!')
}
})
}
})
},
vue iview modal弹出框 form表单验证-LMLPHP
cancleSubmit(name){
this.$refs[name].resetFields();
},

四、效果图

vue iview modal弹出框 form表单验证-LMLPHP

 
05-11 04:32