element form表单只验证一项

element form表单只验证一项

给 form 添加 ref='form'

然后再需要验证的地方加上这段代码即可

this.$refs.form.validateField("password", errMsg => {
  if (errMsg) {
    console.log("校验未通过");
  } else {
    console.log("校验通过");
  }
});

猜你喜欢

转载自blog.csdn.net/Hero_rong/article/details/105772160