在el-dialog中设置必填校验
时间: 2023-10-24 22:26:34 浏览: 158
在el-dialog中设置必填校验,可以通过在el-form-item中使用required属性来实现。例如,可以在el-form-item的rules属性中设置校验规则:
```
<el-form-item label="收货人" prop="receiver">
<el-input v-model="receiver"></el-input>
</el-form-item>
```
设置required校验规则:
```
<el-form-item label="收货人" prop="receiver" :rules="[{ required: true, message: '请输入收货人', trigger: 'blur' }]">
<el-input v-model="receiver"></el-input>
</el-form-item>
```
其中,required为true表示必填,message为提示信息,trigger为触发校验的方式,这里使用blur表示失去焦点时触发校验。你可以根据需要修改这些属性来满足你的实际需求。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [基于element-ui对话框el-dialog初始化的校验问题解决](https://download.csdn.net/download/weixin_38663595/12923444)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [el-dialog校验残留 重置校验失败 resetFileds失效的斗争](https://blog.csdn.net/qq_35630674/article/details/103904617)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文