表格表单校验table-input


      
        
      
    

 要点就是在循环时动态绑定prop和校验规则:

:prop="`tableData.${scope.$index}.${[item.property]}`" 

:rules="formRules[item.property]"

const formRules = reactive({
      nowGoalValue: [fv.isRequired({ msg: '请输入指标值' }), validatorNumberOrDot()],

    })


 try {
          console.log(ruleFormRef.value.validate())
          const valid = await ruleFormRef.value.validate();
          console.log(valid)

          if (valid) {
           ...
          }
        } catch (error) {
          return error;
        }

你可能感兴趣的:(vue项目开发,vue.js,typescript)