共计 649 个字符,预计需要花费 2 分钟才能阅读完成。
<el-form :rules="rules" :model="balanceRecharge" ref="form">
<el-form-item label="充值金额" prop="rechargeAmount">
<el-input placeholder="请输出金额" v-model="balanceRecharge.rechargeAmount">
<template slot="append"> 元 </template>
</el-input>
</el-form-item>
</el-form>
export default {data () {
// 金额验证
let validateAmount = (rule, value, callback) => {if (value) {// let reg = /^[1-9]*[1-9][0-9]*$/;
let reg = /^(([1-9]{1}\d*)|(0{1}))(\.\d{0,2})$/;
if (!reg.test(value)) {callback(new Error('请输出正确的金额!'));
} else {callback();
}
} else {callback(new Error('请输出正确的金额!'));
}
};
return {
balanceRecharge: {rechargeAmount: 0,},
rules: {
rechargeAmount: [{ validator: validateAmount, trigger: ['blur', 'change'], required: true }
]
}
};
},
正文完