#
whycq
2023-09-30 18ed2c710b31951a286a0fb084a0ff041c30416d
components/z-input/z-input.vue
@@ -3,8 +3,8 @@
      <view class="main">
         <view class="inner1">{{desc}}</view>
         <view class="put inner2">
            <input class="p-input" type="text" :placeholder="placeholder" @input="input" v-model="val">
            <uni-icons class="p-icon" type="closeempty" size="16" color="#707070" v-show="val.length" @click="clear"></uni-icons>
            <input class="p-input" type="text" :placeholder="placeholder" @input="input" v-model="data">
            <uni-icons class="p-icon" type="closeempty" size="16" color="#707070" v-show="data.length" @click="clear"></uni-icons>
         </view>
         <view class="inner3" v-show="btn">
            <button class="m-btn" size="mini">{{btnName}}</button>
@@ -16,6 +16,11 @@
<script>
   export default {
      name:"z-input",
      data() {
         return {
            data:'',
         };
      },
      props: {
         desc: {
            type: String,
@@ -43,30 +48,26 @@
         },
      },
      watch: {
         data(val) {
            if (this.data.length != this.lenCheck) {
               console.log(123);
               this.data = val
            }
            this.$emit('input',val)
         },
         value(val) {
            console.log(1);
            this.val = val
            this.data = val
         },
      },
      created() {
         this.val = this.value
      },
      data() {
         return {
            val:'',
         };
         this.data = this.value
      },
      methods: {
         input() {
            console.log(3);
            if(this.val.length != this.lenCheck) {
               this.val = ''
            }
            this.$emit('input',this.val);
         },
         clear() {
            this.val = ''
            this.input()
            this.data = ''
         }
      }
   }