vue里form表单验证

页面部分代码如下:

  <el-dialog title="老师基本信息修改" :visible.sync="detailVisible" width="500px">
    <el-form ref="teacherCheck" :model="form" :rules="teacherRuler">
      <el-form-item label="姓名" label-width="100px" prop="realyName">
        <el-input v-model="form.realyName" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="老师昵称" label-width="100px" prop="nickName">
        <el-input v-model="form.nickName" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="性别" label-width="100px" prop="sex">
        <el-select v-model="form.sex" placeholder="请选择">
          <el-option
            v-for="item in sexs"
            :key="item.code"
            :label="item.name"
            :value="item.code">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="生日" label-width="100px" prop="birthday">
        <el-input v-model="form.birthday" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="头像" label-width="100px" prop="tImg">
        <el-upload
          class="avatar-uploader"
          action="/api/management/header/headUpload"
          :show-file-list="false"
          :on-success="handleAvatarSuccess"
          name="headerImg"
          accept="image/*"
        >
          <img v-if="form.tImg" :src="form.tImg" class="avatar">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </el-form-item>
      <el-form-item label="所属学校" label-width="100px" prop="school">
        <el-input v-model="form.school" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="个性签名" label-width="100px" prop="sign">
        <el-input v-model="form.sign" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="简介" label-width="100px" prop="msg">
        <el-input v-model="form.msg" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="Cancle">取 消</el-button>
      <el-button type="primary" @click="OnSubmit('teacherCheck')">确 定</el-button>
    </div>
  </el-dialog>

方法里部分代码如下:

   //校验规则
   teacherRuler: {
        realyName: [{ required: true, message: "请输入名字", trigger: "blur" }],
        sex: [{ required: true, message: "请输入性别", trigger: "blur" }],
        birthday: [{ required: true, message: "请输入生日", trigger: "blur" }],
        tImg: [{ required: true, message: "请上传头像", trigger: "blur" }],
        nickName: [{ required: true, message: "请输入昵称", trigger: "blur" }],
        school: [
          { required: true, message: "请输入所属学校", trigger: "blur" }
        ],
        sign: [{ required: true, message: "请输入个性签名", trigger: "blur" }],
        msg: [{ required: true, message: "请输入简介", trigger: "blur" }]
      }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值