element-plus中在表格校验输入的值

element-plus中在表格校验输入的值

效果:

注意事项:需要在表单套一个表格的字段

代码:

html 复制代码
<el-form :model="tableFrom" ref="tableDataRef" :rules="rules" style="margin: 0px !important;">
          <el-table class="review-table" :data="tableFrom.tableData" style="width: 100%;">
            <el-table-column prop="name" label="描述" min-width="140" />
            <el-table-column prop="defaultScore" label="分值" header-align="center" align="center" />
            <el-table-column prop="score" label="得分"  >
              <template #default="scope">
                <el-form-item :prop="'tableData[' + scope.$index + '].score'" :rules="rules.score" style="margin-bottom: 0px !important;">
                  <el-input
                    style="width: 70px"
                    placeholder="得分"
                    v-model="tableFrom.tableData[scope.$index].score"
                    type="number"
                    min="0"
                    :max="scope.row.defaultScore"
                  />
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
js 复制代码
const tableFrom = ref({
  tableData:[]
});


const rules = reactive({
  score: [{ required: true, message: '得分不能为空', trigger: 'blur' }],
})
相关推荐
项目題供诗1 分钟前
C语言基础(二)
c语言·开发语言
J_liaty5 分钟前
RabbitMQ面试题终极指南
开发语言·后端·面试·rabbitmq
JosieBook15 分钟前
【开源】基于 C# 和 Halcon 机器视觉开发的车牌识别工具(附带源码)
开发语言·c#
华仔啊16 分钟前
写 CSS 用 px?这 3 个单位能让页面自动适配屏幕
前端·css
逑之29 分钟前
C语言笔记14:结构体、联合体、枚举
c语言·开发语言·笔记
崇山峻岭之间32 分钟前
Matlab学习记录30
开发语言·学习·matlab
stillaliveQEJ36 分钟前
【JavaEE】Spring IoC(二)
java·开发语言·spring
Van_captain36 分钟前
rn_for_openharmony常用组件_Breadcrumb面包屑
javascript·开源·harmonyos
民乐团扒谱机40 分钟前
【微实验】MATLAB 仿真实战:多普勒效应 —— 洒水车音乐的音调变化仿真
开发语言·matlab·多普勒效应·多普勒频移