import React, { useCallback, useState } from 'react' import { View } from '@tarojs/components' import { TextArea } from '@nutui/nutui-react-taro'; import './index.scss' interface TitleTextareaProps { value: string onChange: (value: string) => void maxLength?: number placeholder?: string onFocus?: () => void onBlur?: () => void } const TitleTextarea: React.FC = ({ value='', onChange, maxLength = 20, placeholder = '好的标题更吸引人哦', onFocus, onBlur }) => { const isOverflow = value.length > maxLength // const [isFocused, setIsFocused] = useState(false) // const showPlaceholder = !isFocused && !value const handleChange = useCallback((values) => { // if (values.length > maxLength ) { // const newValues = values.slice(0, maxLength) // onChange(newValues) // return; // } onChange(values) }, [onChange]) const handleFocus = useCallback(() => { // setIsFocused(true) onFocus?.() }, [onFocus]) const handleBlur = useCallback(() => { // setIsFocused(false) onBlur?.() }, [onBlur]) return (