element-ui的rules中正则表达式

在rules中的pattern中写正则表达式

<template>
  <el-form :model="unuseForm" label-position="top" :rules="dialogRules">
    <el-form-item label="原因" prop="loseEfficacyReason">
      <el-input type="textarea" v-model="unuseForm.loseEfficacyReason" auto-complete="off"></el-input>
    </el-form-item>
  </el-form>
</template>
<script>
export default{
  data(){
    return {
      dialogRules: {
        loseEfficacyReason: [
          { required: true, message: '请输入原因', trigger: 'blur' },
          { min: 2, message: '请输入不少于2个字符', trigger: 'blur' },
          { pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+$/, message: '不允许输入空格等特殊符号' }
        ]
      }
    }
  }
}
</script>    

 

posted @ 2018-03-23 16:14  海螺呜呜  阅读(23672)  评论(0编辑  收藏  举报