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' }],
})
相关推荐
Zyx2007几秒前
前端直连大模型:用原生 JavaScript 调用 DeepSeek API
javascript·deepseek
panda4919几秒前
css主流布局
前端·css
一千柯橘1 分钟前
vite 下使用 Module Federation
前端
e***58235 分钟前
TypeScript 与后端开发Node.js
javascript·typescript·node.js
风止何安啊6 分钟前
快 2026 年了,谁还在为 this 挠头?看完这篇让你彻底从懵圈到精通
前端·javascript·node.js
好好研究11 分钟前
SpringMVC框架 - 异常处理
java·开发语言·spring·mvc
烟袅15 分钟前
从零开始:前端如何通过 `fetch` 调用 大模型(详解)
前端·javascript·llm
songroom20 分钟前
Rust: 量化策略回测与简易线程池构建(MPMC)
开发语言·后端·rust
摇滚侠26 分钟前
Vue 项目实战《尚医通》,完成确定挂号业务,笔记46
java·开发语言·javascript·vue.js·笔记
Electrolux32 分钟前
基于WASM的纯前端Office解决方案:在线编辑/导入导出/权限切换(已开源)
前端