1、前端页面
代码语言:javascript复制<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" style="padding: 0 5px">个</span>
</el-input>
</el-form-item>
</el-col>
</el-row>
2、规则验证
代码语言:javascript复制export default {
data() {
return {
ruleForm: {
quantity: "",
},
rules: {
quantity: [{
pattern: /^(([1-9]{1}d*)|(0{1}))(.d{1,2})?$/,
required: true,
message: '请输入数量,且为正整数类型',
trigger: 'blur'
}, ],
},
};
},
若本文有帮助到阅读本文的同学,欢迎点赞、关注、收藏,互相学习交流。