el-table 插入单选并进行校验

javascript 复制代码
<template>
  <div>
    <el-form :model="list" ref="ruleForm">
      <el-table :data="list.tableData" style="width: 100%">
        <el-table-column prop="time" label="日期" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'tableData.' + scope.$index + '.time'" :rules="rules.time">
              <el-input v-model="scope.row.time" maxlength="200" oninput="if(value.length > 4) value=value.slice(0, 4)" placeholder="请输入">
              </el-input>
            </el-form-item>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="180">
          <template slot-scope="scope">
            <el-form-item :prop="'tableData.' + scope.$index + '.name'" :rules="rules.time">
              <el-input v-model="scope.row.name" maxlength="200" oninput="if(value.length > 4) value=value.slice(0, 4)" placeholder="请输入">
              </el-input>
            </el-form-item>
          </template>
        </el-table-column>
      </el-table>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      list: {
        tableData: [
          {
            time: '2016-05-02',
            name: '王小虎'
          },
          {
            time: '2016-05-03',
            name: '王小虎3'
          }
        ]
      },
      rules: {
        time: [
          { required: true, message: '请输入', trigger: 'blur' },
        ]
      }
    }
  }
}
</script>

<style>
</style>
相关推荐
A黄俊辉A9 分钟前
axios+ts封装
开发语言·前端·javascript
小李小李不讲道理34 分钟前
「Ant Design 组件库探索」四:Input组件
前端·javascript·react.js
连合机器人1 小时前
晨曦中的守望者:当科技为景区赋予温度
java·前端·科技
郑板桥301 小时前
tua-body-scroll-lock踩坑记录
前端·javascript
IT古董2 小时前
Vue + Vite + Element UI 实现动态主题切换:基于 :root + SCSS 变量的最佳实践
vue.js·ui·scss
慢半拍iii2 小时前
JAVA Web —— A / 网页开发基础
前端
gnip3 小时前
pnpm 的 monorepo架构多包管理
前端·javascript
新手村领路人4 小时前
Firefox自定义备忘
前端·firefox
乖女子@@@4 小时前
css3新增-网格Grid布局
前端·css·css3
百思可瑞教育4 小时前
使用UniApp实现一个AI对话页面
javascript·vue.js·人工智能·uni-app·xcode·北京百思可瑞教育·百思可瑞教育