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' }],
})
相关推荐
学逆向的6 小时前
汇编——数据存储模式
开发语言·汇编·网络安全
geovindu6 小时前
CSharp: Prototype Pattern
开发语言·后端·设计模式·.net·原型模式·创建型模式
天天进步20157 小时前
Python全栈项目--校园食堂点餐与推荐系统
开发语言·python
aaPIXa6227 小时前
C++模板元编程:编译期计算Fibonacci数列
java·开发语言·c++
eybk7 小时前
写一个可以编制pdf文件的python程序
开发语言·python·pdf
没落英雄7 小时前
5. 从零开始搭建一个 AI Agent —— 人机协作与中断恢复
前端·人工智能·架构
cui_ruicheng7 小时前
Python从入门到实战(八):封装、多态与抽象类
开发语言·python
apihz7 小时前
台风实时与历史详情查询免费 API 接口完整教程
android·开发语言·tcp/ip·dubbo·台风·天气预报
知无不研7 小时前
c语言和c++中的静态关键字
开发语言·c++·静态关键字
品尚公益团队8 小时前
C#在asp.net网页开发中的带cookie登录实现
前端·c#·asp.net