赞
踩
<a-form-item label="市场价" class="status-barcode" name="marketPrice" :rules="[ { required: true, message: '' }, { validator: validateNumber }, ]" > <a-input show-count :maxlength="10" v-model:value="formState.marketPrice" placeholder="市场价" /> </a-form-item>
const objRegExp = {
marketPrice: "市场价格",
};
const NumberRegCommodity = /^(?!0)\d{1,10}$/;
const validateNumber = (rule, value, callback) => {
if (!value) {
return Promise.reject(`请填写${objRegExp[rule.field]}`);
}
if (!NumberRegCommodity.test(value)) {
return Promise.reject("仅限填写正数且首位不能为0");
}
return Promise.resolve();
};
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。