现象
小程序Textarea组件focus键盘弹起时,键盘会挡住部分输入框
cursorSpacing
使用这个属性可以增加Textarea 距离底部的距离,但是自定义导航会被顶起
<Textarea
maxlength={100}
placeholder='写下您的想法吧~'
value={value}
onInput={(e) => setValue(e.detail.value)}
cursorSpacing={120}
disableDefaultPadding
/>
自定义导航问题
因为默认的顶起会把整个page都顶上去,自定义tabbar在页面里也被顶起了, 所以这里把adjustPosition关闭,使用样式来把弹窗抬高达到顶起的效果
const PageContainer = () => {
const [value, setValue] = useState('')
const [boxStyle, setBoxStyle] = useState({})
const handleChangeStyle = (e) => {
setBoxStyle({
paddingBottom: e.detail.height - (system?.includes('iOS') ? 80 : 60),
})
}
return (
<View style={boxStyle}>
<Textarea
maxlength={100}
placeholder='写下您的想法吧~'
value={value}
onInput={(e) => setValue(e.detail.value)}
fixed
adjustPosition={false}
disableDefaultPadding
onKeyboardHeightChange={handleChangeStyle}
/>
</View>
)
}