使用element ui 表单提交验证的时候报错

clipboard.png


methods:{
  applyFree(formName){ 
      let _this = this;
     _this.$refs.formName.validate((valid) => {
     if (valid) {
      debugger;
     } else {
       return false;
     }
    }
  }
    
     ##
阅读 2.4k
2 个回答

自己看啦。
反正<el-form ref="formName">绑定相应 ref
方法里面对应这么拿this.$refs.formName.validate...

methods:{
  applyFree(formName){ 
      let _this = this;
     _this.$refs.formName.validate((valid) => { /*报错,原因_this.$refs.formName不存在,改成_this.$refs[formName]*/
     if (valid) {
      debugger;
     } else {
       return false;
     }
    }
  }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题