赞
踩
name: [{ required: true, message: '必填', trigger: 'change' }]
tel: [{ pattern: /^1\d{10}$/, message: '请填写正确的手机号码', trigger: 'change' }]
area: [{ required: true, validator: this.validateArea, trigger: 'change' }]
- validateArea(rule, value, callback) {
- if(!this.form.provinceCode||!this.form.cityCode||!this.form.districtCode||!this.form.townCode) {
- return callback(new Error('请选择完整行政区域'));
- } else {
- callback()
- }
- },
触发方式
主动触发: this.$refs.form.validateField('area');
取消校验
全部取消:this.$refs.form.clearValidate()
取消指定字段:this.$refs.form.clearValidate(['name'])
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。