1、前端页面
<el-row :gutter="20">
<el-col :span="20">
<el-form-item label="数量" prop="quantity">
<el-input
class="entity"
placeholder="请输入数量"
v-model="ruleForm.quantity"
size="mini"
clearable>
<span slot="suffix" >个</span>
</el-input>
</el-form-item>
</el-col>
</el-row>
2、规则验证
export default {
data() {
return {
ruleForm: {
quantity: "",
},
rules: {
quantity: [{
pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/,
required: true,
message: '请输入数量,且为正整数类型',
trigger: 'blur'
}, ],
},
};
},
若本文有帮助到阅读本文的同学,欢迎点赞、关注、收藏,互相学习交流。