Please enter the code
1. Now you want to validate a bound form data in vuex. The structure is as follows
a: {
b1: {
c: ""
},
b2:"",
b3:""
},
ask everyone how to do it?
Supplementary Code
<el-form :model="formData" :rules="formRule" label-width="100px">
<el-form-item prop="name" label="">
<el-input v-model="formData.name"></el-input>
</el-form-item>
<el-form-item prop="password" label="">
<el-input v-model="formData.password"></el-input>
</el-form-item>
<el-form-item prop="user.tel" label="">
<el-input v-model="formData.user.tel"></el-input>
</el-form-item>
</el-form>
<el-button @click="handleSubmit"></el-button>
export default {
name: "home",
data(){
return {
formData:{
name: "",
password: "",
user: {
tel: ""
}
},
formRule:{
name: [{required: true, message: "", trigger: "blur"},
{pattern: /^[\u4E00-\u9FA5]+$/, message: "", trigger: "blur"}],
password: [{required: true, message: "", trigger: "blur"},],
"user.tel" : [{required: true, message: "", trigger: "blur"}],
},
}
},
methods:{
handleSubmit(){
const t = this;
t.$refs["formData"].validate((valid) => {
if(valid){
console.log(this.formData);
}
})
}
},
}