自定义验证规则:
export default { data() { let verUserName = (rule, value, callback) => { if (value == 1) { return callback(new Error('用户名不能等于1')) } } return { formData: { username: '', password: '', }, rules: { username: [ {validator: verUserName, trigger: 'blur'} ] } }; }, methods: { login: () => { console.log(1) } } }
评论 (0)