vee-validate.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // import Vue from 'vue'
  2. // import VeeValidate, {Validator} from 'vee-validate'
  3. // import zh from 'vee-validate/dist/locale/zh_CN'
  4. // import VueI18n from 'vue-i18n'
  5. //
  6. // Vue.use(VueI18n)
  7. // const i18n = new VueI18n({
  8. // locale: 'zh_CN'
  9. // })
  10. // Vue.use(VeeValidate, {
  11. // i18n,
  12. // i18nRootKey: 'validation',
  13. // dictionary: {
  14. // zh
  15. // }
  16. // })
  17. // 配置中文
  18. // Validator.addLocale(zh)
  19. // const config = {
  20. // locale: 'zh_CN'
  21. // }
  22. // Vue.use(VeeValidate, config)
  23. // 自定义validate
  24. // const dictionary = {
  25. // zh_CN: {
  26. // messages: {
  27. // vipName: () => '用户名不能为空',
  28. // required: (field) => '请输入' + field
  29. // },
  30. // attributes: {
  31. // vipName: '会员名'
  32. // }
  33. // }
  34. // }
  35. // Validator.localize('zh_CN', dictionary)
  36. // 自定义会员名验证
  37. // Validator.extend('vipName', {
  38. // getMessage: field => field + '会员名不能为空',
  39. // validate: value => {
  40. // return value.length === ''
  41. // }
  42. // })
  43. // 自定义手机验证
  44. // Validator.extend('phone', {
  45. // getMessage: field => field + '必须是11位手机号码',
  46. // validate: value => {
  47. // return value.length === 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(value)
  48. // }
  49. // })