在表格中循环插入表单

javascript 复制代码
<template>
  <div class="key">
    {{ruleForm.casesRange}}
    <el-form label-position="top" :model="ruleForm" ref='ruleForm'>
      <el-form-item label="这个表格怎么写">
        <el-table :data="tableData" border>
          <el-table-column prop="time" label="日期" width="180" />
          <el-table-column prop="name" label="名称" width="180" />
          <el-table-column prop="type" label="是否登记(1=是,2=否)" width="180">
            <template slot-scope="scope">
              <el-form-item :prop="'casesRange.' + scope.$index + '.isRegister'" :rules="rules.change">
                <el-radio-group v-model="ruleForm.casesRange[scope.$index].isRegister">
                  <el-radio label="1">是</el-radio>
                  <el-radio label="2">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
    </el-form>

    <el-button type="primary" @click="btn">按钮</el-button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      ruleForm: {
        // 表单
        casesRange: [
          { isRegister: '' },
          { isRegister: '' },
          { isRegister: '' }
        ]
      },
      // 表格数据
      tableData: [
        {
          time: '2016-05-02',
          name: '王小虎'
        },
        {
          time: '2016-05-02',
          name: '王小虎'
        },
        {
          time: '2016-05-02',
          name: '王小虎'
        }
      ],
      rules: {
        change: [
          { required: true, message: '请输入', trigger: 'change' },
        ]
      }
    }
  },
  methods: {
    btn () {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.key {
  width: 600px;
  margin: 0 auto;
  padding: 20px;
}
</style>
相关推荐
GISer_Jing3 小时前
Three.js着色器编译机制深度解析
javascript·webgl·着色器
丷丩3 小时前
MapLibre GL JS第22课:查看本地GeoJSON
前端·javascript·map·mapbox·maplibre gl js
油炸自行车3 小时前
Claude Code 错误:API Error: 400 Failed to deserialize the JSON body into the
开发语言·javascript·json·trae·claude code·api error 400
丷丩7 小时前
MapLibre GL JS第19课:实时更新要素
前端·javascript·gis·map·mapbox·maplibre gl js
xiaohua0708day8 小时前
Lodash库
前端·javascript·vue.js
万物皆对象6668 小时前
切换路由时页面空白问题(vue3)
前端·vue.js·typescript
突然好热8 小时前
TS 调试技巧
前端·javascript·typescript
h64648564h8 小时前
Flutter 国际化(i18n)全指南:一键切换中/英/日多语言
前端·javascript·flutter
丷丩10 小时前
MapLibre GL JS第8课:禁用滚动缩放
javascript·mapbox·maplibre gl js
李剑一10 小时前
小红书前端架构面试问的挺深入啊!面试官:Vue中组合式API与选项式API的设计权衡
vue.js·面试