From c814bf32e899265776cd1e66d611dba02dcaf552 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 25 九月 2023 17:01:45 +0800
Subject: [PATCH] #

---
 components/z-input/z-input.vue |   14 +++++++++++---
 pages/component/demo.vue       |    6 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/components/z-input/z-input.vue b/components/z-input/z-input.vue
index 2d1da6c..ab8a105 100644
--- a/components/z-input/z-input.vue
+++ b/components/z-input/z-input.vue
@@ -4,7 +4,7 @@
 			<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-if="val.length" @click="clear"></uni-icons>
+				<uni-icons class="p-icon" type="closeempty" size="16" color="#707070" v-show="val.length" @click="clear"></uni-icons>
 			</view>
 			<view class="inner3" v-show="btn">
 				<button class="m-btn" size="mini">{{btnName}}</button>
@@ -34,13 +34,17 @@
 				default: '璇疯緭鍏�'
 			},
 			value: {
-				type: [String, Number],
+				type: String,
 				default: ''
+			},
+			lenCheck: {
+				type: [Number],
+				default: null
 			},
 		},
 		watch: {
 			value(val) {
-				console.log(val);
+				console.log(1);
 				this.val = val
 			},
 		},
@@ -54,6 +58,10 @@
 		},
 		methods: {
 			input() {
+				console.log(3);
+				if(this.val.length != this.lenCheck) {
+					this.val = ''
+				}
 				this.$emit('input',this.val);
 			},
 			clear() {
diff --git a/pages/component/demo.vue b/pages/component/demo.vue
index ab32d87..ae8e039 100644
--- a/pages/component/demo.vue
+++ b/pages/component/demo.vue
@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<z-input v-for="it in zInputList" :desc="it.desc" :btn="it.btn" :btn-name="it.btnName" v-model="it.val"></z-input>
+		<z-input v-for="it in zInputList" :desc="it.desc" :btn="it.btn" :btn-name="it.btnName" v-model="it.val" :lenCheck="it.lenCheck"></z-input>
 		<view>杈撳叆妗�1</view>
 		<view>{{zInputList[0].val}}</view>
 		<view>杈撳叆妗�2</view>
@@ -13,8 +13,8 @@
 		data() {
 			return {
 				zInputList: [ 
-					{name: 'yyy',desc: '鎵樼洏鐮�',val: 'a'},
-					{name: 'yyy',desc: '鐗╂枡鐮�',btn: true,btnName: '鎻愬彇',placeholder: '',val: 8}
+					{name: 'yyy',desc: '鎵樼洏鐮�',val: '2',lenCheck: 8},
+					{name: 'yyy',desc: '鐗╂枡鐮�',btn: true,btnName: '鎻愬彇',placeholder: '',val: '1'}
 				],
 				
 			}

--
Gitblit v1.9.1