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' }],
})
相关推荐
ftpeak1 天前
Python win32底层开发从入门到实战
开发语言·python·win32api
阿正的梦工坊1 天前
JavaScript 函数组合(Compose & Pipe)详解
开发语言·javascript·网络
lly2024061 天前
Python uWSGI 安装配置
开发语言
IT_陈寒1 天前
Java集合的这个坑,我调试了整整3小时才爬出来
前端·人工智能·后端
两年半的个人练习生^_^1 天前
每日一学:设计模式之原型模式
java·开发语言·设计模式·原型模式
elseif1231 天前
初学者必背【考点清单(大全)】【上篇】
开发语言·c++·笔记·学习·循环结构·分支结构·考纲
并不喜欢吃鱼1 天前
从零开始C++----二.(下篇)模版进阶与编译全过程的复习
开发语言·c++
23471021271 天前
4.17 学习笔记
开发语言·软件测试·笔记·python·学习
不知名的老吴1 天前
View的三大特性之一:迟绑定
开发语言·c++·算法
深邃-1 天前
【Web安全】-基础环境安装:虚拟机安装,JDK环境安装(1)
java·开发语言·计算机网络·安全·web安全·网络安全·安全架构