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' }],
})
相关推荐
涵信4 分钟前
第九节:React HooksReact 18+新特性-React 19的use钩子如何简化异步操作?
前端·javascript·react.js
Aaaaaaaaaaayou12 分钟前
浅玩一下 Mobile Use
前端·llm
nanzhuhe12 分钟前
python中参数前**的含义
开发语言·python
这个昵称也不能用吗?13 分钟前
react-native搭建开发环境过程记录
前端·react native·cocoapods
hy_花花13 分钟前
Vue3.4之defineModel的用法
前端·vue.js
wt_cs16 分钟前
身份认证C#集成方案-数字时代身份证实名认证利器
开发语言·c#
DataFunTalk27 分钟前
Foundation Agent:深度赋能AI4DATA
前端·后端·算法
hboot29 分钟前
rust 全栈应用框架dioxus
前端·rust·全栈
我是仙女你信不信34 分钟前
生成pdf并下载
前端·javascript·vue.js
少糖研究所34 分钟前
记一次Web Worker的使用
前端·性能优化