如何检验el-table中的el-input

有个页面需要在el-table做输入, 但是希望用户的输入符合要求, 没找到检验的方法, 请高人指点一二

  <el-table-column align="center" label="指标" width="100">
    <template scope="scope">
    <span>{{scope.row.low_quantity}}></span>
    </template>
 </el-table-column>
  <el-table-column align="center" label="数量" width="100">
    <template scope="scope">
    <el-input size="small" v-model="scope.row.quantity"></el-input>
    </template>
 </el-table-column>

我希望用户输入的quantity大于low_quantity, 不知道如何实现

阅读 17.4k
2 个回答

el-table

在这里想对el-table中输入的算法参数做类型判断,代码如下:
(1)html

<el-table-column label="实际值"  width="160" show-overflow-tooltip >
    <template slot-scope="scope">
        <el-form :model="scope.row" :rules="mineForm.checkParamsRule" ref="scope.row" >
             <el-form-item prop="paramValue">
                    <el-input v-show="true" size="small" v-model="scope.row.paramValue" style="width:100px"></el-input>
             </el-form-item>
        </el-form>
    </template>
</el-table-column>

注意:el-form-item的prop和el-input的model要引用正确
(2)js代码
2.1验证说明

checkParamsRule:{
        paramValue:[
                        { validator: validateMineParamsValueInput, trigger: 'blur' }
        ],
},
2.2具体验证器(输入框失去焦点时验证)
//验证挖掘算法输入的参数类型是否正确
var validateMineParamsValueInput = (rule, value, callback) => {
    //输入为空
    if (!value) {
         return callback(new Error('请输入**'))
    } else {
    //自定义验证
         callback()
    }
}

(3)效果图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题