-
先展示修改后可校验的完整 demo
html<template> <div class="rules-container"> <a-form-model ref="formRef" :model="formState" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol" > <a-form-model-item label="Activity name" prop="name"> <a-input v-model="formState.name" /> </a-form-model-item> <a-form-model-item :wrapper-col="{ span: 14, offset: 4 }"> <a-button type="primary" @click="onSubmit">Create</a-button> </a-form-model-item> </a-form-model> </div> </template> <script> export default { name: 'Test', data() { return { formState: { name: '', }, rules: { name: [ { required: true, message: 'Please input Activity name', trigger: 'blur' } ] }, labelCol: { span: 4, }, wrapperCol: { span: 14, }, } }, methods: { onSubmit() { this.$refs.formRef.validate(valid => { if(valid) { console.log('values'); } else{ console.log('error submit!!') return false } }) } } } </script> -
官网:校验生效前提

-
重点

【Ant Design Vue】表单校验 rules 不起作用
May21☀️2024-11-29 9:47
相关推荐
一 乐13 分钟前
汽车租赁|基于SprinBoot+vue的汽车租赁管理系统(源码+数据库+文档)修己xj44 分钟前
打造专属博文封面神器:一个开源免费的博文封面生成器ThisCoverkyriewen1 小时前
面试8家前端岗位后,我发现了一个残酷的事实:AI不是加分项,是门槛Fighting_p1 小时前
【面试 - el-select问题及解决】wujie 微前端下子系统 el-select 多选 filterable 过滤失效吃口巧乐兹1 小时前
AI 全栈时代,为什么要服务端使用 NestJsyingyima1 小时前
Redis 延迟任务队列:凌晨3点服务器报警的救星weiggle1 小时前
第三篇:可组合函数(Composable)——Compose 的基石前端环境观察室1 小时前
别只看 task success:AI Agent 浏览器自动化真正要补的是环境证据链huakoh1 小时前
LangChain 实战:用混合检索啃下 1000 页 PDF,搭一个长文档问答 AgentDazer0071 小时前
Edge 浏览器绕过 HTTPS 证书错误