先上效果图:

在点击确认的时候会验证带有验证的字段

嵌套逻辑:

表单
表格
表格项
表单项
表单项
表格项
表格
表单

代码部分:

<!-- 注意此处的model,需要一个对象,而我们的数据是一个列表,我们列表封装成一个对象放在这里就ok了 这里不需要指定rules-->
<el-form :model="{'sysDictDataList':sysDictDataList}" ref="sysDictDataListRules">
<el-table
:data="sysDictDataList"
style="width: 100%">
<el-table-column
label="字典类型">
<template slot-scope="scope">
<el-form-item>
<el-input v-model="scope.row.dictType" :disabled="true"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="dictType"
label="数据标签">
<template slot-scope="scope">
<!-- 注意此处的prop,需要使用此类型,不能直接填字段名 rules指向该字段的验证规则 -->
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.dictLabel'" :rules="sysDictDataListRules.dictLabel">
<el-input v-model="scope.row.dictLabel" placeholder="请输入数据标签"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="dictType"
label="数据键值">
<template slot-scope="scope">
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.dictValue'" :rules="sysDictDataListRules.dictValue">
<el-input v-model="scope.row.dictValue" placeholder="请输入数据键值"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="dictType"
label="显示排序">
<template slot-scope="scope">
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.dictSort'" :rules="sysDictDataListRules.dictSort">
<el-input-number v-model="scope.row.dictSort" controls-position="right" :min="0"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="备注">
<template slot-scope="scope">
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.remark'" :rules="sysDictDataListRules.remark">
<el-input v-model="scope.row.remark" placeholder="请输入内容"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="状态">
<template slot-scope="scope">
<el-form-item>
<el-radio-group v-model="scope.row.status">
<el-radio
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}
</el-radio>
</el-radio-group>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="操作">
<template slot-scope="scope">
<el-form-item>
<el-button @click="deleteDetails(scope.$index,sysDictDataList)">删除</el-button>
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>

数据:

            sysDictDataList: [],   // 字典详细列表
sysDictDataListRules: { // 字典详细列表的验证
dictLabel: [
{required: true, message: "数据标签不能为空", trigger: "blur"}
],
dictValue:[
{required: true, message: "数据键值不能为空", trigger: "blur"}
],dictSort:[
{required: true, message: "排序不能为空", trigger: "blur"}
],remark:[
{required: true, message: "备注内容不能为空", trigger: "blur"}
]
}

验证方法:

             this.$refs['sysDictDataListRules'].validate(valid =>{
if (valid){
console.log('验证成功,提交');
}
});

注意:如果是根据不同条件展示不同验证表单,使用v-if可能会有意想不到的错误发生,我使用v-show解决此类问题

vue列表中表单的验证的更多相关文章

  1. 关于vue.js中表单控件绑定练习

    html: <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8 ...

  2. Vue iview 表单封装验证

    以下内容转自iview社区,仅供自己查看使用 Form表单部分 <div> <Form ref="FormOne" :model="FormOne&qu ...

  3. elementUI中表格中表单的验证

    表格中的表单验证,就是在将表格放在表单中,将表格绑定的数据也放在表单中. 最重要的是要给表格中需要验证的字段动态添加prop,再给其绑定规则. <el-form :model="tab ...

  4. Bootstrap中表单控件状态(验证状态)

      Bootstrap 表单 http://www.runoob.com/try/try2.php?filename=bootstrap3-form-controlstate (这链接里有简介) &l ...

  5. HTML5中表单验证的8种方法(转)

    在深人探讨表单验证之前,让我们先思考一下表单验证的真实含义.就其核心而言,表单验证是一套系统,它为终端用户检测无效的控件数据并标记这些错误.换言之,表单验证就是在表单提交服务器前对其进行一系列的检查并 ...

  6. HTML5中表单验证的8种方法

    HTML5中表单验证的8种方法 2012-4-21 11:00| 发布者: benben| 查看: 2765| 评论: 0 摘要: 前一篇,我们介绍了HTML5中新的表单特性和函数, 今天就继续来谈谈 ...

  7. YII中表单验证

    关于表单的验证有三种: 1.yii的客户端验证 2.yii的服务器端验证 3.yii的ajax验证 例如: 1.在表单对应的模型中定义一个rules方法(该方添加后,在表单提交时,将自动被调用) pu ...

  8. angular 中表单验证的探索

    需求 之前有一段时间做一个搜索查询 但是有很多限制条件,如果校验不成功需要给用户提示错误,当然项目用的是组件库的校验 我能否自己写一个? 其实 我是不会的!!! 探索 angular 的校验功能很强大 ...

  9. spring boot中表单验证的使用

    一.前言 为啥子要搞这个表单验证呢?答案简单而现实,举个栗子,你辛辛苦苦的写了一个录入个人信息的功能,比如年龄这个位置,用户就没看到一下子写了个性别男,一提交,直接报错了,是不是很尴尬呢, 作为一个测 ...

随机推荐

  1. Mybatis与Spring整合(纯注解)

    java1.5版本之后开始支持注解,spring*2开始提供注解配置方式,到spring**4后spring推荐使用注解配置 IOC注解(主要作用就是在spring容器中声明一个Bean,同xml中的 ...

  2. CocoaPods 安装和使用 - darcy_tang 的博客

    最近换了新机器,重新搭建了开发环境,其中当然包括 CocoaPods. 装完顺便更新下 CocoaPods 安装文档. 正文 安装 CocoaPods 是用 ruby 实现的,要想使用它首先需要有 r ...

  3. understanding android build layer · Dylan

    build / android 先看看Android官方的解释 Understand Build Layers The build hierarchy includes the abstraction ...

  4. CSS面试题&知识点汇总

    问题&答案 介绍一下标准的CSS的盒子模型?低版本IE的盒子模型有什么不同的? 有两种, IE 盒子模型.W3C 盒子模型: 盒模型: 内容(content).填充(padding).边界(m ...

  5. 数据检索|文献检索|事实检索|yandex|Title vs topic|检索技术|检索技巧|

    信息检索: 信息检索原理是,将书写不规范的原始数据先存储,再通过归纳化or标准化手段进行拆分,便于用户搜索. 信息检索类型可依据数据内容进行分类,文献检索是通过输入关键字进入搜索引擎,搜索仅找到含有关 ...

  6. JVM之工具分析

    JVM分析工具有很多; jdk自带工具:jconsole.jvisualvm 其他工具:jprofile ,yourkit等 不要在线上用,影响性能,在测试环境中使用. 一.jconsole ——jd ...

  7. svn merge Property conflicts

    svn merge代码的时候,出现Property conflicts的解决方案.可以参考:http://stackoverflow.com/questions/23677286/conflict-w ...

  8. 修改xampp中phpmyadmin用户管理

    用相关软件打开位于D:/xampp/phpMyAdmin文件夹中的config.inc.php文件. 搜索$cfg['Servers'][$i]['auth_type'] = 'config'; 将其 ...

  9. Koa 学习

    中间件引擎 1234567891011121314151617181920212223242526272829303132333435363738 const Koa = require('koa') ...

  10. Jenkins+Git+Fastlane+Fir CI集成

    上一篇有讲关于fastlane自动化部署,本篇将会着重讲关于fastlane的实际应用. 目标: 利用自动化jenkins打包工具,自动拉取git仓库代码 不需要通过手动检查修改xcode中项目配置修 ...