vue循环绑定v-model
直接上代码
结构:
<repayInput v-if="formData" v-for="(item, index) in formData"
:isPwd="item.parameter_code==='password'"
:text="item.parameter_name.replace('社保网站','')"
:textAlign="'right'"
:errText="arrForm[index][`arr${item.parameter_code}`]"
@changeErrText="_changeErrText2($event,index,'arr'+item.parameter_code)"
:type="item.parameter_code"
:maxlength="item.parameter_code==='name'?'15':'50'"
:placeholder="item.parameter_message"
v-model="arrForm[index][item.parameter_code]" :key="index">
</repayInput>
组织arrForm数据
_this.arrForm.length = 0;
// debugger
let obj = _this.formInfo[_this.socialType.value].tabs[selectedVal[selectedVal.length-1]].field;
for(var j=0; j<obj.length; j++) {
var strObj = `{"${obj[j].parameter_code}":"","arr${obj[j].parameter_code}":"","type":"${obj[j].parameter_code}","name${obj[j].parameter_code}":"${obj[j].parameter_name}"}`;
// Vue.set(_this.arrForm, obj[j].parameter_code, '');
// Vue.set(_this.arrForm, `arr${obj[j].parameter_code}`,'');
_this.arrForm.push(JSON.parse(strObj))
}
表单验证:
//验证动态表单 this.arrForm
let _this = this;
for(var i=0; i< _this.arrForm.length; i++) {
var cur = _this.arrForm[i];
if( !rValidate.isEmpty(cur[cur.type],() => {
cur['arr'+cur.type] = cur['name'+cur.type] + '不能为空';
}) ){
dyPro = false;
}
if( cur.type === 'id_card_num' ){
if( cur[cur.type]!==_this.query.cardNo ) {//验证是否与借款人是同一人
cur['arr'+cur.type] = '请输入身份认证时身份证账号';
dyPro = false;
}
}
if( cur.type === 'cell_phone_num' ){
if( !rValidate.mobile(cur[cur.type],() => {
cur['arr'+cur.type] = '手机号码格式错误';
}) ) {
dyPro = false;
}
}
}
组织需要提交的数据:
//组织表单参数 applyInfo _this.arrForm
let applyInfo = {};
for(var i=0; i< _this.arrForm.length; i++) {
var cur = _this.arrForm[i];
applyInfo[cur.type] = cur[cur.type];
}
query_.applyInfo = applyInfo;
vue循环绑定v-model的更多相关文章
- vue双向绑定的原理及实现双向绑定MVVM源码分析
vue双向绑定的原理及实现双向绑定MVVM源码分析 双向数据绑定的原理是:可以将对象的属性绑定到UI,具体的说,我们有一个对象,该对象有一个name属性,当我们给这个对象name属性赋新值的时候,新值 ...
- Vue双向绑定原理,教你一步一步实现双向绑定
当今前端天下以 Angular.React.vue 三足鼎立的局面,你不选择一个阵营基本上无法立足于前端,甚至是两个或者三个阵营都要选择,大势所趋. 所以我们要时刻保持好奇心,拥抱变化,只有在不断的变 ...
- vue双向绑定原理及实现
vue双向绑定原理及实现 一.总结 一句话总结:vue中的双向绑定主要是通过发布者-订阅者模式来实现的 发布 订阅 1.单向绑定和双向绑定的区别是什么? model view 更新 单向绑定:mode ...
- [Vue源码]一起来学Vue双向绑定原理-数据劫持和发布订阅
有一段时间没有更新技术博文了,因为这段时间埋下头来看Vue源码了.本文我们一起通过学习双向绑定原理来分析Vue源码.预计接下来会围绕Vue源码来整理一些文章,如下. 一起来学Vue双向绑定原理-数据劫 ...
- vue双向绑定原理分析
当我们学习angular或者vue的时候,其双向绑定为我们开发带来了诸多便捷,今天我们就来分析一下vue双向绑定的原理. 简易vue源码地址:https://github.com/jiangzhenf ...
- vue双向绑定原理源码解析
当我们学习angular或者vue的时候,其双向绑定为我们开发带来了诸多便捷,今天我们就来分析一下vue双向绑定的原理. 简易vue源码地址:https://github.com/maxlove123 ...
- Vue双向绑定实现原理demo
一.index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> ...
- Vue双向绑定的实现原理系列(四):补充指令解析器compile
补充指令解析器compile github源码 补充下HTML节点类型的知识: 元素节点 Node.ELEMENT_NODE(1) 属性节点 Node.ATTRIBUTE_NODE(2) 文本节点 N ...
- Vue双向绑定的实现原理系列(一):Object.defineproperty
了解Object.defineProperty() github源码 Object.defineProperty()方法直接在一个对象上定义一个新属性,或者修改一个已经存在的属性, 并返回这个对象. ...
随机推荐
- Linux 安装ngnix
第一步:把nginx的源码包上传到linux系统/home 第二步:解压缩 [root@localhost ~]# tar zxf nginx-1.8.0.tar.gz 第三步:使用configure ...
- Vision-Based Positioning for Internet-of-Vehicles
Vision-Based Positioning for Internet-of-Vehicles Introduction Ego-positioning aims at locating an o ...
- 02_Linux 终端命令格式
01. 终端命令格式 command [-options] [parameter] 说明: command:命令名,相应功能的英文单词或单词的缩写 [-options]:选项,可用来对命令进行控制,也 ...
- 修改状态栏,电池,wifi的颜色为白色
修改状态栏,电池,wifi的颜色为白色 在info里面设置View controller-based status bar appearance,为no
- poj_2084_Game of Connections
This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, . . . , 2n - 1 ...
- Java中Redis缓存
1:安装 安装可分为单机版redis 和集群版redis 安装比较简单,自行百度即可 2:集成 pom文件中加入jedis 依赖,spring创建redis的application-resid配置, ...
- 使用Win32DiskImager后重置SD卡
再1.Windows diskpart命令 diskpart 2.列出所有的磁盘 lisk disk 3.选择U盘所在的磁盘 4.清除磁盘 clean 5.创建主分区 create primary p ...
- 数据结构的C语言基础
数据结构的C语言基础 1. 数据输出 printf()函数为格式输出函数,它存在于标准函数库中,在C语言程序中可以直接调用,但程序源文件的开头必须包含以下命令: #include < stdi ...
- 转:python教程专题资源免费下载整理合集收藏
python教程专题资源免费下载整理合集收藏 < Python学习手册(第4版)>(Learning Python, 4th Edition)[PDF] 94MB 简体中文 <Pyt ...
- Git 克隆指定分支代码
git clone 指定分支 拉代码 1.git clone 不指定分支 git clone http://10.1.1.11/service/sz-service.git 2.git clone ...