el-form-item validator 携带额外的参数

<el-form-item :prop="'group.' + index + '.checkNum.' + i + '.maxValue'" class="class-cell" :rules="{
    required: true,
    trigger: 'change',
    validator: discountEqualMax(its)
}" >
    <el-input v-model="its.maxValue" placeholder="数字" style="width: 100px;" />
el-form-item>
function discountEqualMax (its: any) {
    return (rule: any, value: any, callback: any) => {
        console.log(its, 'ssssss')
        const reg = /(^[1-9]\d*$)/;
        if (value === null || value === '') {
            callback(new Error('请输入数值'));
        } else if (value < 1 || value > 999999) {
            callback(new Error('请输入0-999999数值'));
        } else if (reg.test(value) === false) {
            callback(new Error('只能输入整数'));
        } else {
            callback();
        }
    }
};

你可能感兴趣的:(Vue.js,vue.js,javascript,前端)