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' }],
})
相关推荐
Justin3go5 小时前
HUNT0 上线了——尽早发布,尽早发现
前端·后端·程序员
Tony Bai6 小时前
高并发后端:坚守 Go,还是拥抱 Rust?
开发语言·后端·golang·rust
怕浪猫6 小时前
第一章 JSX 增强特性与函数组件入门
前端·javascript·react.js
铅笔侠_小龙虾6 小时前
Emmet 常用用法指南
前端·vue
wjs20246 小时前
Swift 类型转换
开发语言
钦拆大仁6 小时前
跨站脚本攻击XSS
前端·xss
前端小L7 小时前
贪心算法专题(十):维度权衡的艺术——「根据身高重建队列」
javascript·算法·贪心算法
秃了也弱了。7 小时前
python实现定时任务:schedule库、APScheduler库
开发语言·python
weixin_440730507 小时前
java数组整理笔记
java·开发语言·笔记