From 4a6ac73ad77d2542b36a783e2d958cb14980a97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E9=87=8E?= Date: Mon, 26 Jan 2026 22:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=9C=AC=E5=9F=9F?= =?UTF-8?q?=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TextareaTag/TextareaTag.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/TextareaTag/TextareaTag.tsx b/src/components/TextareaTag/TextareaTag.tsx index 484c009..e2b475d 100644 --- a/src/components/TextareaTag/TextareaTag.tsx +++ b/src/components/TextareaTag/TextareaTag.tsx @@ -29,8 +29,10 @@ const TextareaTag: React.FC = ({ // 处理文本输入变化 const handleTextChange = useCallback((val: string) => { console.log(val,'e.detail.value') - onChange({...value, description: val}) - }, [onChange]) + const maxAllowedLength = Math.floor(maxLength * 1.2) + const truncatedVal = val.length > maxAllowedLength ? val.slice(0, maxAllowedLength) : val + onChange({...value, description: truncatedVal}) + }, [onChange, maxLength, value]) // 处理标签选择变化 const handleTagChange = useCallback((selectedTags: string[]) => {