<el-form :model="form" :rules="rules" ref="form" label-width="100px"> <el-form-item label="活动名称" prop="name"> <el-input v-model="form.name"></el-input> </el-form-item> </el-form>
rules: { name:[ { required: true, message: '请输入活动名称', trigger: 'blur' },{ pattern: /^[0-9 a-z A-Z]*$/, message: "只允许输入数字或字母或数字与字母的组合" },{ min: 1, max: 20, message: "长度在 1 到 20 个字符" } ], },