Element 表单验证,取消部分表单字段校验结果
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
<template>
<div>
<el-form ref="formRules" :model="form" :rules="rules" :inline="true">
<el-form-item prop="name">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item prop="age" ref="ageForm">
<el-input v-model="form.age"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="validate">验证</el-button>
<el-button type="primary" @click="cancelFieldValidate">取消</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: `clearFieldValidate`,
data () {
return {
formRules: '',
form: {
name: '',
age: ''
},
rules: {
name: [
{ required: true, message: '请输入姓名!', trigger: 'blur' }
],
age: [
{ required: true, message: '请输入年龄!', trigger: 'blur' }
]
}
}
},
methods: {
validate () {
this.$refs.formRules.validate(valid => {
if (valid) {
this.$message.success('(^o^)~ 验证成功!')
} else {
this.$message.error('-_- 验证失败!')
}
})
},
cancelFieldValidate () {
this.$refs['ageForm'].clearValidate() // 清除年龄的验证
}
}
}
</script>
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45
6 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)