Does elementUI form validation have to be written this way? RuleForm.name

clipboard.png

this is an example of the official website:

<el-form :model="ruleForm" :rules="rules" ref="ruleForm">
  <el-form-item label="" prop="name">
    <el-input v-model="ruleForm.name"></el-input>
  </el-form-item>
  <el-button type="primary" @click="submit()"></el-button>
</el-form>
------------------------------
  ruleForm:{
    name:"",
  },
  rules:{
    name:[
      {
        required: true, 
        message: "", 
        trigger: "blur"
      }
    ]
  }

my question:

<el-input v-model="ruleForm.name"></el-input>

isn"t it okay for me to change the way I write ruleForm.name, in this place like this?

<el-input v-model="name"></el-input>

the verification of this writing method will be invalid. I"m not used to it.


element-ui verification rules, you need to add: rules= "rules" to the form tag el-form, and then the verification rules corresponding to the binding prop on the input box input in the form
are as follows:

<el-form :model="ruleForm" :rules="rules" ref="ruleForm">
  <el-form-item label="" prop="checkName">
    <el-input v-model="ruleForm.name"></el-input>
  </el-form-item>
</el-form>
------------------------------
  ruleForm:{
    name:"",
  },
  rules:{
    checkName:[
      {
        required: true, 
        message: '', 
        trigger: 'blur'
      }
    ]
  }

change the form input box prop= "checkName" corresponding to name = > checkName, in rules

as for the bound input vmurm model = "name", it should be bound according to el-form: model= "ruleForm" lai, so your original way of writing vmurl model = "ruleForm.name" is fine

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e86d6f-e0b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e86d6f-e0b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?