立即创建重置varMain={data(){return{ruleForm:{turnTrip:'',initReadings:'',desc:''},rules:{turnTrip:[{required:true,validator:(rule,value,callback)=>{if(!value){callback(newError('请输入回程'));}if(value{if(valid){alert('submit!');}else{console.log('errorsubmit!!');returnfalse;}});},resetForm(formName){this.$refs[formName].resetFields();}}}varCtor=Vue.extend(Main)newCtor().$mount('#app')@importurl("//unpkg.com/element-ui@2.5.4/lib/theme-chalk/index.css");https://jsfiddle.net/vx3mftb4/2/
2 回答
慕的地8271018
TA贡献1796条经验 获得超4个赞
varfirstNumber=(rule,value,callback)=>{if(!value){callback(newError("请输入初始读数"));}if(value<0){callback(newError("必须大于0"));}else{if(this.dataForm.turnTrip>value){callback();}else{callback(newError("回程必须大于初始读数"));}}};以上这样放在data()跟return之间就OK。
哈士奇WWW
TA贡献1799条经验 获得超6个赞
rules:{turnTrip:[{required:true,validator:(rule,value,callback)=>{if(!value){callback(newError('请输入回程'));}if(value<0){callback(newError('必须大于0'));}else{callback();}},trigger:"blur"},type:'number'],initReadings:[{required:true,message:'请输入初始读数',trigger:'change',type:'number'}],}
添加回答
举报
0/150
提交
取消