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' }],
})
相关推荐
用户409932250212几秒前
Vue中默认插槽、具名插槽、作用域插槽如何区分与使用?
前端·vue.js·github
tod1132 分钟前
Redis - 客户端基本介绍
开发语言·数据库·redis·缓存
zheshiyangyang5 分钟前
前端面试基础知识整理【Day-3】
前端·word
赵谨言7 分钟前
运用Python编程计算减压孔板孔口直径的研究
大数据·开发语言·经验分享·python
用户982361079027711 分钟前
Vite 项目优化分包填坑之依赖多版本冲突问题深度解析与解决方案
前端
陆枫Larry14 分钟前
深入浅出:CSS 中的“隐形结界”——BFC 详解
前端·css
njsgcs14 分钟前
用python打开exe 不闪退 0x01000000 # CREATE_BREAKAWAY_FROM_JOB
开发语言·python
wuhen_n15 分钟前
JavaScript 深拷贝的完全解决方案
前端·javascript
大时光16 分钟前
gsap 配置解读 --3
前端
橙露20 分钟前
全栈开发入门:Python Flask+Vue3 搭建前后端分离的博客系统
开发语言·python·flask