Chr*_*son 8 react-native react-native-android
onContentSizeChange
在Android上似乎无法正常启动.事件被触发mount
,但不会在text height
更改时触发.相同的代码适用于iOS:
<TextInput
editable = {true}
multiline = {true}
[...]
onContentSizeChange={(event) => {
this.setState({height: event.nativeEvent.contentSize.height});
}}
style={{height: Math.max(35, this.state.height)}}
/>
Run Code Online (Sandbox Code Playgroud)
https://github.com/facebook/react-native/issues/6552#issuecomment-269989962
在Android onContentSizeChange
中只调用一次onChange
而不是onContentSizeChange
.
码
<TextInput
editable = {true}
multiline = {true}
[...]
onChange={(event) => {
this.setState({height: event.nativeEvent.contentSize.height});
}}
style={{height: Math.max(35, this.state.height)}}
/>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3624 次 |
最近记录: |