功能介绍:利用v-for循环批量生成el-input组件,并对指定el-input带rules验证。
1、template
<el-form
:model="searchForm"
:rules="rules"
ref="ruleForm"
label-width="100px"
>
<div v-for="(item, index) in searchForm.list" :key="index">
<el-form-item
:label="item.label"
:prop="'list.' + index + '.value'"
:rules="item.rules.value"
>
<el-input
v-model="item.value"
:placeholder="item.placeHolder"
></el-input>
</el-form-item>
</div>
</el-form>
2、data
data() {
return {
searchForm: {
list: [
{
index: 1,
value: "",
label: "名称:",
placeHolder: "请输入",
rules: {
value: [
{ required: true, message: "请输入名称", trigger: "blur" }
]
}
},
{
index: 2,
value: "",
label: "年龄:",
placeHolder: "请输入",
rules: {
value: [{ required: false }]
}
},
{
index: 1,
value: "",
label: "身份证号:",
placeHolder: "请输入",
rules: {
value: [
{ required: true, message: "请输入身份证号", trigger: "blur" }
]
}
}
]
},
rules: {}
}
}
v-for批量生成el-input并动态绑定v-model(实时获取input输入值和索引)
上面是“v-for循环生成el-input带rules验证”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2535.html
workflows工作流
一把令人难忘的美丽吉他ComfyUI工作流
一个以破旧的怀旧史努比玩偶
一只可爱的快乐老鼠戴着帽子ComfyUI工作流
一个巨大的漆黑的蟹王ComfyUI工作流
一棵白色心形流苏树comfyui工作流
嘴唇丰满的漂亮女人
基础扩图comfyui工作流
一块慕斯蛋糕ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

利用css3做一个动态loading效果
html5如何3D立方体旋转特效
css3+js菜单点击动态效果
jquery做一个漂亮挂墙动态时钟
css3绘制一个会动的大嘴鸟
css3结合svg做一个动态广告
css3搭积木叠加图形
iframe开发admin后台










