index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <u-toast ref="uToast"></u-toast>
  7. <view class="u-no-demo-here" style="text-align: left;">
  8. 这里仅对部分验证规则进行演示,目前总的验证规则有如下:
  9. </view>
  10. <u-table style="margin-top: 20rpx;">
  11. <u-tr>
  12. <u-td>邮箱号</u-td>
  13. <u-td>手机号</u-td>
  14. <u-td>URL</u-td>
  15. <u-td>普通日期</u-td>
  16. </u-tr>
  17. <u-tr>
  18. <u-td>十进制数</u-td>
  19. <u-td>身份证号</u-td>
  20. <u-td>车牌号</u-td>
  21. <u-td>金额</u-td>
  22. </u-tr>
  23. <u-tr>
  24. <u-td>汉字</u-td>
  25. <u-td>字母</u-td>
  26. <u-td>字母|数字</u-td>
  27. <u-td>包含值</u-td>
  28. </u-tr>
  29. <u-tr>
  30. <u-td>数值范围</u-td>
  31. <u-td>长度范围</u-td>
  32. <u-td width="50%"></u-td>
  33. </u-tr>
  34. </u-table>
  35. </view>
  36. </view>
  37. <view class="u-config-wrap">
  38. <view class="u-config-title u-border-bottom">
  39. 参数配置
  40. </view>
  41. <view class="u-config-item">
  42. <view class="u-item-title">邮箱</view>
  43. <u-subsection :list="email" @change="emailChange"></u-subsection>
  44. </view>
  45. <view class="u-config-item">
  46. <view class="u-item-title">手机号</view>
  47. <u-subsection :list="mobile" @change="mobileChange"></u-subsection>
  48. </view>
  49. <view class="u-config-item">
  50. <view class="u-item-title">中文</view>
  51. <u-subsection :list="chinese" @change="chineseChange"></u-subsection>
  52. </view>
  53. <view class="u-config-item">
  54. <view class="u-item-title">整数</view>
  55. <u-subsection :list="digits" @change="digitsChange"></u-subsection>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. email: ['google@gmail.com', 'google艾特gmail.com'],
  65. mobile: ['13478561273', '0778-3423082'],
  66. chinese: ['天青色等烟雨', 'Beat it'],
  67. digits: [283, '下雨的声音']
  68. }
  69. },
  70. methods: {
  71. toast(type) {
  72. this.$refs.uToast.show({
  73. type: type ? 'success' : 'error',
  74. title: type ? '验证通过' : '验证失败'
  75. })
  76. },
  77. emailChange(index) {
  78. this.toast(this.$u.test.email(this.email[index]));
  79. },
  80. mobileChange(index) {
  81. this.toast(this.$u.test.mobile(this.mobile[index]));
  82. },
  83. chineseChange(index) {
  84. this.toast(this.$u.test.chinese(this.chinese[index]));
  85. },
  86. digitsChange(index) {
  87. this.toast(this.$u.test.digits(this.digits[index]));
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .u-demo {}
  94. </style>