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' }],
})
相关推荐
OpenTiny社区几秒前
TinyEngine 低代码实时协作揭秘:原理 +实操,看完直接用!
前端·vue.js·低代码
likuolei几秒前
XML 元素 vs. 属性
xml·java·开发语言
X***48965 分钟前
C源代码生成器
c语言·开发语言
梁正雄10 分钟前
2、Python流程控制
开发语言·python
catchadmin35 分钟前
PHP True Async RFC 被拒——原生异步离 PHP 还有多远?
开发语言·php
J***793936 分钟前
PHP在电商中的Magento
开发语言·php
5***790037 分钟前
Vue项目性能优化
前端·javascript·vue.js
丫丫7237341 小时前
Three.js 模型树结构与节点查询学习笔记
javascript·webgl
车传新1 小时前
Javascript
javascript
python零基础入门小白1 小时前
【万字长文】大模型应用开发:意图路由与查询重写设计模式(从入门到精通)
java·开发语言·设计模式·语言模型·架构·大模型应用开发·大模型学习