element-ui的rules中正則表達式

<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> 

  

在rules中的pattern中寫正則表達式javascript

相關文章
相關標籤/搜索