Browse Source

feat: field demo

guoxiaoxiao8 5 years ago
parent
commit
8c07da866e
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/packages/field/demo.vue

+ 11 - 2
src/packages/field/demo.vue

@@ -36,7 +36,7 @@
     <div>
       <nut-cell>
         <span slot="title">
-          <nut-field  v-model="val5" :state="state"  :requireShow="true" label="手机号码"   />
+          <nut-field  v-model="val5" :state="state"  :requireShow="true" label="手机号码"  @inputFunc="checkVal5" />
         </span>
       </nut-cell>
     </div> 
@@ -64,7 +64,7 @@
        <div>
       <nut-cell>
         <span slot="title">
-          <nut-field label="标题内容:" placeholder="请输入内容" v-model="val" inputFunc="a" />
+          <nut-field label="标题内容:" placeholder="请输入内容" v-model="val" @inputFunc="a" />
         </span>
       </nut-cell>
     </div>
@@ -107,6 +107,15 @@ export default {
     a(data){
       console.log(data)
     },
+    checkVal5(data){
+      if(!(/^1[3456789]\d{9}$/.test(data))){ 
+       console.log(false)
+       this.state="error";
+      } else{
+         console.log(true)
+        this.state="";
+      }
+    },
     submit() {
       this.$refs.myInput.blur();
     }