Merge branch 'master' of http://git.bimwe.com/tennis/mini-programs
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import { View } from '@tarojs/components'
|
import { View } from '@tarojs/components'
|
||||||
import { TextArea } from '@nutui/nutui-react-taro'
|
import { TextArea } from '@nutui/nutui-react-taro';
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
interface TitleTextareaProps {
|
interface TitleTextareaProps {
|
||||||
@@ -20,14 +21,22 @@ const TitleTextarea: React.FC<TitleTextareaProps> = ({
|
|||||||
onFocus,
|
onFocus,
|
||||||
onBlur
|
onBlur
|
||||||
}) => {
|
}) => {
|
||||||
|
const handleChange = useCallback((values) => {
|
||||||
|
if (values.length > maxLength ) {
|
||||||
|
const newValues = values.slice(0, maxLength)
|
||||||
|
onChange(newValues)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onChange(values)
|
||||||
|
}, [])
|
||||||
return (
|
return (
|
||||||
<View className='title-input-wrapper'>
|
<View className='title-input-wrapper'>
|
||||||
<TextArea
|
<TextArea
|
||||||
className='title-input'
|
className='title-input'
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
onInput={(e) => onChange(e.detail.value)}
|
onInput={(e) => handleChange(e.detail.value)}
|
||||||
maxlength={maxLength}
|
// maxlength={maxLength}
|
||||||
autoSize={true}
|
autoSize={true}
|
||||||
placeholderClass='title-input-placeholder'
|
placeholderClass='title-input-placeholder'
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
|
|||||||
Reference in New Issue
Block a user