Przeglądaj źródła

feat(活动注册): 输入框掩码

曾志翔 3 lat temu
rodzic
commit
2a8f6a476d
2 zmienionych plików z 5 dodań i 15 usunięć
  1. 2 0
      pages/activity/invite-user/register.vue
  2. 3 15
      plugins/v-mask.js

+ 2 - 0
pages/activity/invite-user/register.vue

@@ -14,6 +14,7 @@
             >
               <v-text-field
                 v-model="form.phone"
+                v-mask="$mask.phone"
                 label=""
                 name="phone"
                 required
@@ -33,6 +34,7 @@
             >
               <v-text-field
                 v-model="form.code"
+                v-mask="'######'"
                 label=""
                 :error-messages="errors"
                 name="code"

+ 3 - 15
plugins/v-mask.js

@@ -3,23 +3,11 @@ import VueMask from 'v-mask';
 Vue.use(VueMask);
 
 // 身份证
-const idCard = (value) => {
-  // 前17位数字
-  const mask = Array.from({ length: 17 }).fill(/\d/);
-  // 最后一位数字或X
-  mask.push(/(\d|X|x)/);
-  return mask;
-};
+const idCard = [...Array.from({ length: 17 }).fill(/\d/), /(\d|X|x)/];
 
-const phone = (value) => {
-  const mask = [/1/, ...Array.from({ length: 10 }).fill(/\d/)];
-  return mask;
-};
+const phone = [/1/, ...Array.from({ length: 10 }).fill(/\d/)];
 
-const bankCard = (value) => {
-  const mask = Array.from({ length: 20 }).fill(/\d/);
-  return mask;
-};
+const bankCard = Array.from({ length: 20 }).fill(/\d/);
 
 export default function (c, i) {
   i('mask', {