当前位置:网站首页>el-form表单新增表单项动态校验;el-form校验动态表单v-if不生效;
el-form表单新增表单项动态校验;el-form校验动态表单v-if不生效;
2022-07-01 05:07:00 【i_am_a_div_日积月累_】
一、新增和删除表单项,动态校验。
el-form表单动态动态新增表单进行校验。直接参考 动态增减表单项
二、el-form表单校验v-if不生效、el-form表单校验v-show不生效:
例如有个表单项,通过控制显示两个不同的表单项内容,分别需要校验对应的表单项即可。
如果是直接用v-if,会发现切换时候,校验不生效;
如果直接使用v-show,又发现即使不切换,隐藏了另外的表单项,也会触发校验规则。
正确做法是:使用v-if控制表单项的显示隐藏,同时需要给el-form-item加上自己的 prop=" " 和 key=" " ,这样才能区分。当然:rules 也要有自己对应的提示。
<template v-if="flag">
<el-form-item label="姓名:" prop="name" key="name" :rules="rules.name">
<el-input v-model="formData.name" placeholder=""></el-input>
</el-form-item>
</template>
<template v-else>
<el-form-item label="退回原因:" prop="desc" key="desc" :rules="rules.desc">
<el-input type="textarea" maxlength="500" show-word-limit v-model="formData.desc" placeholder="请填写退回原因"></el-input>
</el-form-item>
</template>
边栏推荐
- Quelques outils dont les chiens scientifiques pourraient avoir besoin
- [daily question in summer] Luogu p2026 find the analytic formula of primary function
- LeetCode_ 35 (search insertion position)
- Global and Chinese market of 3D design and modeling software 2022-2028: Research Report on technology, participants, trends, market size and share
- LeetCode_ 53 (maximum subarray and)
- 分布式事务-解决方案
- Implementation of distributed lock
- Pico neo3 handle grabs objects
- Pytoch (II) -- activation function, loss function and its gradient
- Is there any good website or software for learning programming? [introduction to programming]?
猜你喜欢
STM32 光敏电阻传感器&两路AD采集
Basic skeleton of neural network nn Use of moudle
STM32扩展板 温度传感器和温湿度传感器的使用
STM32 extended key scan
Solution: drag the Xib control to the code file, and an error setvalue:forundefined key:this class is not key value coding compliant for the key is reported
【暑期每日一题】洛谷 P5886 Hello, 2020!
Manually implement a simple stack
Tcp/ip explanation (version 2) notes / 3 link layer / 3.2 Ethernet and IEEE 802 lan/man standards
Vmware workstation network card settings and three common network modes
解决:拖动xib控件到代码文件中,报错setValue:forUndefinedKey:this class is not key value coding-compliant for the key
随机推荐
FileOutPutStream
Pytoch (IV) -- visual tool visdom
Global and Chinese market of broadband amplifiers 2022-2028: Research Report on technology, participants, trends, market size and share
Copy baby prompt: material cannot be empty. How to solve it?
【暑期每日一题】洛谷 P3742 umi的函数
LeetCode1497-检查数组对是否可以被 k 整除-数组-哈希表-计数
Global and Chinese market of paper machine systems 2022-2028: Research Report on technology, participants, trends, market size and share
Quelques outils dont les chiens scientifiques pourraient avoir besoin
Copier le matériel de conseils de bébé ne peut pas être vide, comment résoudre?
RuntimeError: “max_pool2d“ not implemented for ‘Long‘
STM32 光敏电阻传感器&两路AD采集
AcWing 885. Find the combination number I (recursive preprocessing)
【暑期每日一题】洛谷 P1568 赛跑
Technology sharing | broadcast function design in integrated dispatching
Programmers dig "holes" to get rich: if they find a loophole, they will be rewarded 12.72 million yuan
Go learning notes (5) basic types and declarations (4)
解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *
STM32扩展板 温度传感器和温湿度传感器的使用
HCIP Day13
Leetcode522- longest special sequence ii- hash table - String - double pointer