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[]) => {