鍍金池/ 問答/HTML/ 使用element ui 表單提交驗證的時候報錯

使用element ui 表單提交驗證的時候報錯

clipboard.png


methods:{
  applyFree(formName){ 
      let _this = this;
     _this.$refs.formName.validate((valid) => {
     if (valid) {
      debugger;
     } else {
       return false;
     }
    }
  }
    
     ##
回答
編輯回答
凹凸曼

自己看啦。
反正<el-form ref="formName">綁定相應(yīng) ref
方法里面對應(yīng)這么拿this.$refs.formName.validate...

2017年6月22日 01:47
編輯回答
陪她鬧
methods:{
  applyFree(formName){ 
      let _this = this;
     _this.$refs.formName.validate((valid) => { /*報錯,原因_this.$refs.formName不存在,改成_this.$refs[formName]*/
     if (valid) {
      debugger;
     } else {
       return false;
     }
    }
  }
2018年4月18日 20:40