功能介绍:利用v-for循环批量生成el-input组件,动态绑定v-model,并且实时获取input输入值和索引。
1、template
<el-form>
<el-form-item
v-for="(item, index) in searchForm"
:key="index"
:label="item.title"
>
<el-input
:type="item.type"
v-model="item.modelName"
@input.native="change($event, index)"
:placeholder="item.placeholder"
></el-input>
</el-form-item>
</el-form>2、data
data() {
return {
searchForm: [
{
type: "text",
title: "用户名",
placeholder: "输入用户名",
modelName: "web建站"
},
{
type: "password",
title: "旧密码",
placeholder: "输入旧密码",
modelName: "ipkd.cn"
},
{
type: "password",
title: "新密码",
placeholder: "输入新密码",
modelName: "ipkd.cn"
}
],
userName: "",
password1: "",
password2: ""
};
},
3、methods
methods: {
change: function(e, index) {
if (index === 0) {
this.userName = e.target.value;
console.log("用户名:", this.userName);
} else if (index === 1) {
this.password1 = e.target.value;
console.log("原密码", this.password1);
} else if (index === 2) {
this.password2 = e.target.value;
console.log("新密码", this.password2);
}
}
}
上面是“v-for批量生成el-input并动态绑定v-model(实时获取input输入值和索引)”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2534.html
workflows工作流
一只可爱的小鸟在飞翔ComfyUI工作流
骨骼般的恶魔修女ComfyUI工作流
海中一头鲸鱼ComfyUI工作流
五彩斑斓的蛇状飞鸟
一辆老式灵车在黑暗中从雾中出现ComfyUI工作流
文生图工作流:一幅海底睡莲,碧海蓝天comfyui工
一条精致透明的朱红色水晶龙
一个黑人在森林中穿着折纸的衣服ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

如何利用svg做一个有趣的loading动画加载
做一个好玩的时钟翻牌效果
css3实现星球旋转
利用html5+css3实现滚雪球效果(附代码)
会议人员60s签到倒计时插件
纯css制作卡通头像(随鼠标转头)
利用js做一个炫酷音乐背景效果
css3卡片动态滑动效果












