Home  >  Article  >  Web Front-end  >  Issues related to vue form validation in element

Issues related to vue form validation in element

亚连
亚连Original
2018-06-11 10:41:202147browse

This article mainly introduces the solution of element combined with vue under form verification, but prompting an error when there is a value. Friends who need it can refer to it

The bound value must be the same as the value specified by the rule -------

Step one:

<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">

Add rules ref

Part two:

<el-form-item label="活动名称" prop="name"> <el-input v-model="ruleForm.name"></el-input> </el-form-item>

Add prop

Part 3:

rules: {
name: [
{ required: true, message: &#39;请输入活动名称&#39;, trigger: &#39;blur&#39; },
{ min: 3, max: 5, message: &#39;长度在 3 到 5 个字符&#39;, trigger: &#39;blur&#39; }
],
resource: [
{ required: true, message: &#39;请选择活动资源&#39;, trigger: &#39;change&#39; }
],
}

If required is added here, there is no need to add it after the prop; for other detailed verifications here, please see the document

Part 4: Click to submit the form

(Here is a place to remember , 334b5aebba827cf6498410b3c5899927Submit form7485571ee57e8f18a622e724e109ecc3 This must be enclosed in quotation marks, get it done

submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {

Here is what to do after the verification is successful

} else {
console.log(&#39;error submit!!&#39;);
return false;
}
});
},

The above is what I compiled for everyone, I hope it will be helpful to everyone in the future.

Related articles:

How to get the specified index value with jquery

How to implement the side sliding menu in MUI

The problem of off-canvas sliding beyond the part in the mui framework

How to use better-scroll in vue2.0 to realize mobile sliding

Using cli mui in Vue related to area scrolling issues

Online paid courses in vue (detailed tutorial)

The above is the detailed content of Issues related to vue form validation in element. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn