gpt4 book ai didi

javascript - 在不使用事件的情况下获取 TextInput 高度

转载 作者:行者123 更新时间:2023-12-01 15:47:49 24 4
gpt4 key购买 nike

我实际上有一个这样的 TextInput :

<TextInput
onChange={(event) => {
this.setState({
text: event.nativeEvent.text,
height: event.nativeEvent.contentSize.height,
});
}}
editable={!this.state.load}
style={{height: this.state.inputFocused == true || this.state.text.length > 0 || this.state.picture.uri != undefined ? Math.max(height / 11.8, this.state.height) : height / 2.5, width: width, backgroundColor: 'white', fontFamily: 'Aller', fontSize: width / 24, padding: width / 38, alignItems: 'flex-start', justifyContent: 'flex-start', textAlignVertical: 'top',}}
multiline={true}
value={this.state.text}
/>

我正在使用此 TextInput 添加内容但也添加到 编辑 ,所以我用 TextInput 和 height 中的默认值初始化使用它的类,并且 textInput 的高度不会按照我的意愿自动调整。

那么如何在不使用任何事件的情况下获取 textInput 中文本占用的高度?

最佳答案

只是不要给它一个高度样式,所以它不会得到任何高度并匹配它的内容高度

关于javascript - 在不使用事件的情况下获取 TextInput 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42585678/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com